Skip to main content

Router

Struct Router 

Source
pub struct Router {
    pub router: Option<Eui>,
    pub muxs: Option<Eui>,
    pub uri: Option<String>,
    pub error: Option<String>,
}
Expand description

What the discovery endpoint answers: where to connect, or why not.

Fields§

§router: Option<Eui>

The station, as the server read it.

§muxs: Option<Eui>

The server endpoint that will carry the session.

§uri: Option<String>

The websocket to open, absolute.

§error: Option<String>

Why the station was refused, when it was.

Implementations§

Source§

impl Router

Source

pub fn accepted(router: Eui, muxs: Eui, uri: impl Into<String>) -> Router

Answers a station with the websocket to open.

§Arguments
  • router - the station being answered.
  • muxs - the server endpoint carrying the session.
  • uri - the websocket address.
§Returns

The answer.

Source

pub fn refused(router: Eui, error: impl Into<String>) -> Router

Refuses a station, saying why.

§Arguments
  • router - the station being refused.
  • error - what is wrong, in words the operator can act on.
§Returns

The answer.

Source

pub fn to_json(&self) -> String

Writes the answer.

§Returns

The JSON body.

Source

pub fn from_json(body: &[u8]) -> Result<Router, ProtocolError>

Reads the answer, as a station does.

§Arguments
  • body - the answer body.
§Returns

The answer, whose error says whether the station was refused.

§Errors

Returns ProtocolError::Payload when the body is not JSON.

Trait Implementations§

Source§

impl Clone for Router

Source§

fn clone(&self) -> Router

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Router

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Router

Source§

fn default() -> Router

Returns the “default value” for a type. Read more
Source§

impl Eq for Router

Source§

impl PartialEq for Router

Source§

fn eq(&self, other: &Router) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Router

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.