pub struct SendMessageContext<'a> { /* private fields */ }
Expand description

Handles the process of actually sending a message over the connection it was created from. This allows graceful handling of short writes or timeouts with only parts of the message written. You can loop over write or write_once or use write_all to wait until all bytes have been written or an error besides a timeout arises.

Implementations§

source§

impl SendMessageContext<'_>

source

pub fn serial(&self) -> u32

source

pub fn resume<'a>( conn: &'a mut SendConn, msg: &'a MarshalledMessage, progress: SendMessageState ) -> SendMessageContext<'a>

Resume a SendMessageContext from the progress. This needs to be called with the same conn and msg that were used to create the original SendMessageContext.

source

pub fn into_progress(self) -> SendMessageState

Turn this into the progress to resume the sending later. Note that you cannot send another message while doing that. You need to resume a SendMessageContext from this progress and send the current message beofre starting the next one.

source

pub fn force_finish(self)

only call if you deem the connection doomed by an error returned from writing. The connection might be left in an invalid state if some but not all bytes of the message have been written

source

pub fn write(self, timeout: Timeout) -> Result<u32, (Self, Error)>

Try writing as many bytes as possible until either no more bytes need to be written or the timeout is reached. For an infinite timeout there is write_all as a shortcut

source

pub fn write_all(self) -> Result<u32, (Self, Error)>

Block until all bytes have been written

source

pub fn bytes_total(&self) -> usize

How many bytes need to be sent in total

source

pub fn all_bytes_written(&self) -> bool

Check if all bytes have been written

source

pub fn write_once(&mut self, timeout: Timeout) -> Result<usize, Error>

Basic routine to do a write to the fd once. Mostly useful if you are using a nonblocking timeout. But even then I would recommend using write() and not write_once()

Trait Implementations§

source§

impl<'a> Debug for SendMessageContext<'a>

source§

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

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

impl Drop for SendMessageContext<'_>

This panics if the SendMessageContext was dropped when it was not yet finished. Use force_finish / force_finish_on_error if you want to do this. It will be necessary for handling errors that make the connection unusable.

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for SendMessageContext<'a>

§

impl<'a> Send for SendMessageContext<'a>

§

impl<'a> Sync for SendMessageContext<'a>

§

impl<'a> Unpin for SendMessageContext<'a>

§

impl<'a> !UnwindSafe for SendMessageContext<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.