Trait SerWrite

Source
pub trait SerWrite {
    type Error;

    // Required method
    fn write(&mut self, buf: &[u8]) -> Result<(), Self::Error>;

    // Provided methods
    fn write_byte(&mut self, byte: u8) -> Result<(), Self::Error> { ... }
    fn write_str(&mut self, s: &str) -> Result<(), Self::Error> { ... }
}
Expand description

Serializers should write data to the implementations of this trait.

Required Associated Types§

Source

type Error

An error type returned from the trait methods.

Required Methods§

Source

fn write(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write all bytes from buf to the internal buffer.

Otherwise return an error.

Provided Methods§

Source

fn write_byte(&mut self, byte: u8) -> Result<(), Self::Error>

Write a single byte to the internal buffer.

Return an error if the operation could not succeed.

Source

fn write_str(&mut self, s: &str) -> Result<(), Self::Error>

Write a whole string to the internal buffer.

Otherwise return an error.

Implementations on Foreign Types§

Source§

impl SerWrite for VecDeque<u8>

Available on crate features std or alloc only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

fn write_byte(&mut self, byte: u8) -> SerResult<()>

Source§

impl SerWrite for Vec<u8>

Available on crate features std or alloc only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

fn write_byte(&mut self, byte: u8) -> SerResult<()>

Source§

impl SerWrite for SliceVec<'_, u8>

Available on crate feature tinyvec only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

impl<T> SerWrite for Cursor<T>
where Cursor<T>: Write,

Available on crate feature std only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

impl<T: SerWrite> SerWrite for &mut T

Source§

type Error = <T as SerWrite>::Error

Source§

fn write(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Source§

fn write_byte(&mut self, byte: u8) -> Result<(), Self::Error>

Source§

fn write_str(&mut self, s: &str) -> Result<(), Self::Error>

Source§

impl<const CAP: usize> SerWrite for TinyVec<[u8; CAP]>
where [u8; CAP]: Array<Item = u8>,

Available on crate feature tinyvec and (crate features std or alloc) only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

impl<const CAP: usize> SerWrite for ArrayVec<u8, CAP>

Available on crate feature arrayvec only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

fn write_byte(&mut self, byte: u8) -> SerResult<()>

Source§

impl<const CAP: usize> SerWrite for Vec<u8, CAP>

Available on crate feature heapless only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

fn write_byte(&mut self, byte: u8) -> SerResult<()>

Source§

impl<const CAP: usize> SerWrite for SmallVec<[u8; CAP]>
where [u8; CAP]: Array<Item = u8>,

Available on crate feature smallvec only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

fn write_byte(&mut self, byte: u8) -> SerResult<()>

Source§

impl<const CAP: usize> SerWrite for ArrayVec<[u8; CAP]>
where [u8; CAP]: Array<Item = u8>,

Available on crate feature tinyvec only.
Source§

type Error = SerError

Source§

fn write(&mut self, buf: &[u8]) -> SerResult<()>

Source§

fn write_byte(&mut self, byte: u8) -> SerResult<()>

Implementors§