Struct WireWriter

Source
pub struct WireWriter<'a, const E: bool = true> { /* private fields */ }

Implementations§

Source§

impl<'a, const E: bool> WireWriter<'a, E>

Source

pub fn new(bytes: &'a mut [u8]) -> Self

Create a WireWriter that can write data types sequentially to the bytes slice.

Source

pub fn advance(&mut self, amount: usize) -> Result<(), WireError>

Advance the writer’s index forward by the given amount of bytes, returning an error if there are insufficient bytes on the wire to do so.

Source

pub fn advance_up_to(&mut self, amount: usize)

Advance the writer’s index forward by the given number of bytes, or to the end of the wire if the amount exceeds the number of remaining bytes.

Source

pub fn finalize(&self) -> Result<(), WireError>

Check if the writer has no more bytes left on the wire that can be written to. If any bytes remain, return WireError::ExtraBytes; otherwise, return Ok().

Source

pub fn finalize_after<T>( action: Result<(), WireError>, reader: &Self, ) -> Result<(), WireError>

Check if the writer has no more bytes left on the wire that can be written to after the given action. If any bytes remain, return WireError::ExtraBytes; otherwise, return Ok().

Source

pub fn is_empty(&self) -> bool

Check whether the writer has any remaining bytes that can be written to.

Source

pub fn write<T>(&mut self, writable: &T) -> Result<(), WireError>
where T: WireWrite + ?Sized,

Write the given data type writable to the wire.

Source

pub fn write_part<T, const L: usize>( &mut self, writable: &T, ) -> Result<(), WireError>
where T: WireWritePart,

Write the given data type writable to L bytes on the wire.

Trait Implementations§

Source§

impl From<WireWriter<'_>> for WireIndex

Source§

fn from(writer: WireWriter<'_>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, const E: bool> Freeze for WireWriter<'a, E>

§

impl<'a, const E: bool> RefUnwindSafe for WireWriter<'a, E>

§

impl<'a, const E: bool> Send for WireWriter<'a, E>

§

impl<'a, const E: bool> Sync for WireWriter<'a, E>

§

impl<'a, const E: bool> Unpin for WireWriter<'a, E>

§

impl<'a, const E: bool = true> !UnwindSafe for WireWriter<'a, E>

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.