Skip to main content

Message

Struct Message 

Source
pub struct Message {
    pub msg_type: MessageType,
    pub session: Option<SessionId>,
    pub channel: Option<String>,
    pub payload: Option<MessagePayload>,
}
Expand description

A message sent between frontend, relay, and backend.

All messages carry a type field that identifies the variant, an optional session ID for session-scoped messages, and a type-specific payload.

Fields§

§msg_type: MessageType

Message type identifier (e.g. “input”, “output”, “resize”).

§session: Option<SessionId>

Session ID, present on session-scoped messages.

§channel: Option<String>

The channel inside the session a message belongs to, for a backend that carries several of its machine’s sessions in one relay session: an opaque ID (valid_channel), never a session’s name. The relay sets it on what a frontend sends (the channel it joined), and sends the backend’s output on a channel only to the frontends that joined it. Left out for the session as a whole.

§payload: Option<MessagePayload>

Type-specific payload data.

Implementations§

Source§

impl Message

Source

pub fn on_channel(self, channel: Option<String>) -> Self

This message, on channel.

Source§

impl Message

Source

pub fn session_create() -> Self

Create a new session creation message.

Source

pub fn session_create_replaying() -> Self

Create a session creation message from a backend that replays recent output to joining frontends.

Source

pub fn session_join(session: SessionId) -> Self

Create a new session join message.

Source

pub fn session_join_with_history( session: SessionId, history: u32, rows: u16, ) -> Self

Create a session join that asks for history lines of the session’s history before its screen (#92), for a terminal of rows rows; with none asked, a plain join.

Source

pub fn session_joined(session: SessionId, frontend_token: String) -> Self

Create a session joined confirmation, as a frontend gets it.

Source

pub fn session_created( session: SessionId, frontend_token: String, resume_secret: String, ) -> Self

Create a session joined confirmation for the backend that created or resumed the session, with its resume secret.

Source

pub fn session_resume(session: SessionId, secret: String) -> Self

Create a session resume request.

Source

pub fn frontend_joined( session: SessionId, frontend: u64, history: u32, rows: u16, ) -> Self

Create a notice to the backend that a frontend joined.

Source

pub fn replay(session: SessionId, frontend: u64, data: Vec<u8>) -> Self

Create a replay of recent output for a joining frontend.

Source

pub fn backend_away(session: SessionId) -> Self

Create a notice that the session’s backend dropped.

Source

pub fn backend_back(session: SessionId) -> Self

Create a notice that the session’s backend is back.

Source

pub fn session_left(session: SessionId) -> Self

Create a session left message.

Source

pub fn session_error(session: Option<SessionId>, reason: String) -> Self

Create a session error message; session is None for an error that comes before the connection has a session (a failed auth, say).

Source

pub fn input(session: SessionId, data: Vec<u8>) -> Self

Create an input (keyboard/mouse) message.

Source

pub fn paste_input(session: SessionId, data: Vec<u8>) -> Self

Create an input message for bytes inside a bracketed paste.

Source

pub fn output(session: SessionId, data: Vec<u8>) -> Self

Create an output (terminal) message.

Source

pub fn sealed_resize(session: SessionId, data: Vec<u8>) -> Self

Create a resize message carrying a sealed size.

Source

pub fn resize(session: SessionId, columns: u16, rows: u16) -> Self

Create a resize message with the size in clear.

Source

pub fn auth(token: String) -> Self

Create an authentication message carrying token.

Source

pub fn ping() -> Self

Create a ping (keep-alive) message.

Source

pub fn pong() -> Self

Create a pong (heartbeat response) message.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Self

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 Message

Source§

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

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

impl<'de> Deserialize<'de> for Message

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Message

Source§

impl PartialEq for Message

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Message

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Message

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.