Struct PreMessageChannel

Source
pub struct PreMessageChannel<T, R>
where T: Serialize, R: for<'des> Deserialize<'des>,
{ /* private fields */ }
Expand description

A sendable handle for establishing MessageChannels with processes you can already communicate with.

PreMessageChannels are created in pairs, and then can be freely sent along any IPC method in this crate capable of transmitting OS resources. When they reach their destination they can be converted into MessageChannels.

Implementations§

Source§

impl<T, R> PreMessageChannel<T, R>
where T: Serialize, R: for<'de> Deserialize<'de>,

Source

pub fn pair(max_message_size: usize) -> Result<(Self, Self)>

Source

pub fn into_channel( self, remote_process: ProcessHandle, tokio_loop: &TokioHandle, ) -> Result<MessageChannel<T, R>>

Creates a MessageChannel from a transmitted pre-channel and a remote process handle.

§Security

You should only allow more trusted processes to hold unsealed channels to less trusted processes. On some platforms unsealed channels allow the holder to interfere with the other process.

Using an incorrect remote process handle may cause this function to fail or transmission of OS resources (files, sockets, etc.) accross the channel to fail.

Source

pub fn into_sealed_channel( self, tokio_loop: &TokioHandle, ) -> Result<MessageChannel<T, R>>

Creates a sealed MessageChannel from a transmitted pre-channel.

Sealed channels cannot transmit OS resources (files, sockets, etc.) but can still transmit data (they may receive OS resources if the other side is unsealed). It is recommended that you use a sealed channel handle when communicating from the less trusted side of a channel.

Trait Implementations§

Source§

impl<T, R> Debug for PreMessageChannel<T, R>
where T: Serialize + Debug, R: for<'des> Deserialize<'des> + Debug,

Source§

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

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

impl<'de, T, R> Deserialize<'de> for PreMessageChannel<T, R>
where T: Serialize, R: for<'des> Deserialize<'des>,

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<T, R> Serialize for PreMessageChannel<T, R>
where T: Serialize, R: for<'des> Deserialize<'des>,

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

Auto Trait Implementations§

§

impl<T, R> Freeze for PreMessageChannel<T, R>

§

impl<T, R> RefUnwindSafe for PreMessageChannel<T, R>

§

impl<T, R> Send for PreMessageChannel<T, R>
where T: Send, R: Send,

§

impl<T, R> Sync for PreMessageChannel<T, R>
where T: Sync, R: Sync,

§

impl<T, R> Unpin for PreMessageChannel<T, R>
where T: Unpin, R: Unpin,

§

impl<T, R> UnwindSafe for PreMessageChannel<T, R>
where T: UnwindSafe, R: UnwindSafe,

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> 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, 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,