#[non_exhaustive]pub enum Message {
Ping,
Pong,
JoinRelayRequest {
token: String,
},
JoinSessionRequest {
key: Vec<u8>,
},
Response {
code: i32,
message: String,
},
ConnectRequest {
id: Vec<u8>,
},
SessionInvitation {
from: Vec<u8>,
key: Vec<u8>,
address: Vec<u8>,
port: u16,
server_socket: bool,
},
RelayFull,
}Expand description
One bep-relay control message.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Ping
Periodic keepalive sent by either side.
Pong
Keepalive acknowledgement.
JoinRelayRequest
Join the relay registration with an optional access token.
JoinSessionRequest
Propose to join an existing session with its shared key.
Response
Status reply to a previous request.
ConnectRequest
Ask the relay to broker a session towards a device id.
SessionInvitation
An invitation to a session, delivered to the dialed device on its registered connection and to the dialing device on the fresh connection that carried the connection request.
RelayFull
The relay has no capacity left.
Implementations§
Source§impl Message
impl Message
Sourcepub const RESPONSE_SUCCESS: i32 = 0
pub const RESPONSE_SUCCESS: i32 = 0
Response code for a successful request.
Sourcepub const RESPONSE_NOT_FOUND: i32 = 1
pub const RESPONSE_NOT_FOUND: i32 = 1
Response code: the dialed device is unknown to the relay.
Sourcepub const RESPONSE_ALREADY_CONNECTED: i32 = 2
pub const RESPONSE_ALREADY_CONNECTED: i32 = 2
Response code: the device is already connected to the relay.
Sourcepub const RESPONSE_WRONG_TOKEN: i32 = 3
pub const RESPONSE_WRONG_TOKEN: i32 = 3
Response code: the join token was rejected.
Sourcepub const RESPONSE_UNEXPECTED: i32 = 100
pub const RESPONSE_UNEXPECTED: i32 = 100
Response code: an unexpected message arrived.
Sourcepub fn encode_frame(&self) -> Result<Vec<u8>>
pub fn encode_frame(&self) -> Result<Vec<u8>>
Encode self into a complete wire frame (header + payload).
§Errors
Returns an error if the payload exceeds MAX_MESSAGE_LENGTH.
Sourcepub fn decode_frame(frame: &[u8]) -> Result<Self>
pub fn decode_frame(frame: &[u8]) -> Result<Self>
Decode a complete wire frame (header + payload) into a message.
§Errors
Returns an error if the frame is malformed, truncated, or carries an unknown message type.
Trait Implementations§
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more