Trait WireWrite

Source
pub trait WireWrite {
    // Required method
    fn write_wire<const E: bool>(
        &self,
        curs: &mut WireCursorMut<'_>,
    ) -> Result<(), WireError>;
}
Expand description

Serialization from a data type to the wire.

A type that implements this trait guarantees that it can be serialized into a number of bytes that will be written to the provided WireCursorMut. If the bytes cannot be written to the wire, an error will be returned.

Required Methods§

Source

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Serializes the data type into a number of bytes on the wire, or returns a WireError on failure.

The generic boolean E designates the intended endianness of the data being written. If E is set to true, then the data will be serialized in big endian format; if false, it will be serialized in little endian.

§Errors

WireError::InsufficientBytes - not enough bytes remained on the cursor to write the type to the wire.

WireError::Internal - an internal error occurred in the wire-rs library

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl WireWrite for f32

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for f64

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for i8

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for i16

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for i32

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for i64

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for i128

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for isize

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for str

Source§

fn write_wire<'a, const E: bool>( &self, curs: &mut WireCursorMut<'a>, ) -> Result<(), WireError>

Source§

impl WireWrite for u8

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for u16

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for u32

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for u64

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for u128

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for usize

Source§

fn write_wire<const E: bool>( &self, curs: &mut WireCursorMut<'_>, ) -> Result<(), WireError>

Source§

impl WireWrite for [u8]

Source§

fn write_wire<'a, const E: bool>( &self, curs: &mut WireCursorMut<'a>, ) -> Result<(), WireError>

Implementors§