pub struct WriteCursor<'b> { /* private fields */ }
Expand description

A cursor over a byte slice for easy serializing of Cyphal data types

Functions that write values will panic if no space is available in the slice.

Implementations§

source§

impl<'b> WriteCursor<'b>

source

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

Creates a cursor that will write starting at the beginning of the provided slice

source

pub fn is_aligned_to_8_bits(&self) -> bool

Returns true if this cursor is aligned to a multiple of 8 bits

source

pub fn write_aligned_u8(&mut self, value: u8)

Writes an 8-bit integer

Panics

This function panics if the cursor is not aligned to a multiple of 8 bits.

source

pub fn write_aligned_u16(&mut self, value: u16)

Writes a 16-bit integer

Panics

This function panics if the cursor is not aligned to a multiple of 8 bits.

source

pub fn write_aligned_u32(&mut self, value: u32)

Writes a 32-bit integer

Panics

This function panics if the cursor is not aligned to a multiple of 8 bits.

source

pub fn write_aligned_u64(&mut self, value: u64)

Writes a 64-bit integer

Panics

This function panics if the cursor is not aligned to a multiple of 8 bits.

source

pub fn align_to_8_bits(&mut self)

Advances the cursor to a byte boundary (a multiple of 8 bits)

source

pub fn write_f16(&mut self, value: f16)

Writes a 16-bit floating-point value

source

pub fn write_f32(&mut self, value: f32)

Writes a 32-bit floating-point value

source

pub fn write_f64(&mut self, value: f64)

Writes a 64-bit floating-point value

source

pub fn write_bytes(&mut self, bytes: &[u8])

Writes a byte array

source

pub fn write_aligned_bytes(&mut self, bytes: &[u8])

Writes a sequence of bytes

Panics

This function panics if the cursor is not aligned to a multiple of 8 bits.

source

pub fn write_composite<T>(&mut self, value: &T)where T: Serialize,

Writes a composite value, aligned to 8 bits

source

pub fn write_bool(&mut self, value: bool)

Writes a boolean value (1 bit)

source

pub fn bits_written(&self) -> usize

Returns the number of bits that have been written to this cursor

source§

impl WriteCursor<'_>

source

pub fn write_u1(&mut self, value: u8)

Writes a 1-bit unsigned integer

source

pub fn write_u2(&mut self, value: u8)

Writes a 2-bit unsigned integer

source

pub fn write_u3(&mut self, value: u8)

Writes a 3-bit unsigned integer

source

pub fn write_u4(&mut self, value: u8)

Writes a 4-bit unsigned integer

source

pub fn write_u5(&mut self, value: u8)

Writes a 5-bit unsigned integer

source

pub fn write_u6(&mut self, value: u8)

Writes a 6-bit unsigned integer

source

pub fn write_u7(&mut self, value: u8)

Writes a 7-bit unsigned integer

source

pub fn write_u8(&mut self, value: u8)

Writes a 8-bit unsigned integer

source

pub fn write_u9(&mut self, value: u16)

Writes a 9-bit unsigned integer

source

pub fn write_u10(&mut self, value: u16)

Writes a 10-bit unsigned integer

source

pub fn write_u11(&mut self, value: u16)

Writes a 11-bit unsigned integer

source

pub fn write_u12(&mut self, value: u16)

Writes a 12-bit unsigned integer

source

pub fn write_u13(&mut self, value: u16)

Writes a 13-bit unsigned integer

source

pub fn write_u14(&mut self, value: u16)

Writes a 14-bit unsigned integer

source

pub fn write_u15(&mut self, value: u16)

Writes a 15-bit unsigned integer

source

pub fn write_u16(&mut self, value: u16)

Writes a 16-bit unsigned integer

source

pub fn write_u17(&mut self, value: u32)

Writes a 17-bit unsigned integer

source

pub fn write_u18(&mut self, value: u32)

Writes a 18-bit unsigned integer

source

pub fn write_u19(&mut self, value: u32)

Writes a 19-bit unsigned integer

source

pub fn write_u20(&mut self, value: u32)

Writes a 20-bit unsigned integer

source

pub fn write_u21(&mut self, value: u32)

Writes a 21-bit unsigned integer

source

pub fn write_u22(&mut self, value: u32)

Writes a 22-bit unsigned integer

source

pub fn write_u23(&mut self, value: u32)

Writes a 23-bit unsigned integer

source

pub fn write_u24(&mut self, value: u32)

Writes a 24-bit unsigned integer

source

pub fn write_u25(&mut self, value: u32)

Writes a 25-bit unsigned integer

source

pub fn write_u26(&mut self, value: u32)

Writes a 26-bit unsigned integer

source

pub fn write_u27(&mut self, value: u32)

Writes a 27-bit unsigned integer

source

pub fn write_u28(&mut self, value: u32)

Writes a 28-bit unsigned integer

source

pub fn write_u29(&mut self, value: u32)

Writes a 29-bit unsigned integer

source

pub fn write_u30(&mut self, value: u32)

Writes a 30-bit unsigned integer

source

pub fn write_u31(&mut self, value: u32)

Writes a 31-bit unsigned integer

source

pub fn write_u32(&mut self, value: u32)

Writes a 32-bit unsigned integer

source

pub fn write_u33(&mut self, value: u64)

Writes a 33-bit unsigned integer

source

pub fn write_u34(&mut self, value: u64)

Writes a 34-bit unsigned integer

source

pub fn write_u35(&mut self, value: u64)

Writes a 35-bit unsigned integer

source

pub fn write_u36(&mut self, value: u64)

Writes a 36-bit unsigned integer

source

pub fn write_u37(&mut self, value: u64)

Writes a 37-bit unsigned integer

source

pub fn write_u38(&mut self, value: u64)

Writes a 38-bit unsigned integer

source

pub fn write_u39(&mut self, value: u64)

Writes a 39-bit unsigned integer

source

pub fn write_u40(&mut self, value: u64)

Writes a 40-bit unsigned integer

source

pub fn write_u41(&mut self, value: u64)

Writes a 41-bit unsigned integer

source

pub fn write_u42(&mut self, value: u64)

Writes a 42-bit unsigned integer

source

pub fn write_u43(&mut self, value: u64)

Writes a 43-bit unsigned integer

source

pub fn write_u44(&mut self, value: u64)

Writes a 44-bit unsigned integer

source

pub fn write_u45(&mut self, value: u64)

Writes a 45-bit unsigned integer

source

pub fn write_u46(&mut self, value: u64)

Writes a 46-bit unsigned integer

source

pub fn write_u47(&mut self, value: u64)

Writes a 47-bit unsigned integer

source

pub fn write_u48(&mut self, value: u64)

Writes a 48-bit unsigned integer

source

pub fn write_u49(&mut self, value: u64)

Writes a 49-bit unsigned integer

source

pub fn write_u50(&mut self, value: u64)

Writes a 50-bit unsigned integer

source

pub fn write_u51(&mut self, value: u64)

Writes a 51-bit unsigned integer

source

pub fn write_u52(&mut self, value: u64)

Writes a 52-bit unsigned integer

source

pub fn write_u53(&mut self, value: u64)

Writes a 53-bit unsigned integer

source

pub fn write_u54(&mut self, value: u64)

Writes a 54-bit unsigned integer

source

pub fn write_u55(&mut self, value: u64)

Writes a 55-bit unsigned integer

source

pub fn write_u56(&mut self, value: u64)

Writes a 56-bit unsigned integer

source

pub fn write_u57(&mut self, value: u64)

Writes a 57-bit unsigned integer

source

pub fn write_u58(&mut self, value: u64)

Writes a 58-bit unsigned integer

source

pub fn write_u59(&mut self, value: u64)

Writes a 59-bit unsigned integer

source

pub fn write_u60(&mut self, value: u64)

Writes a 60-bit unsigned integer

source

pub fn write_u61(&mut self, value: u64)

Writes a 61-bit unsigned integer

source

pub fn write_u62(&mut self, value: u64)

Writes a 62-bit unsigned integer

source

pub fn write_u63(&mut self, value: u64)

Writes a 63-bit unsigned integer

source

pub fn write_u64(&mut self, value: u64)

Writes a 64-bit unsigned integer

source§

impl WriteCursor<'_>

source

pub fn skip_1(&mut self)

Advances the cursor to skip 1 bit

source

pub fn skip_2(&mut self)

Advances the cursor to skip 2 bits

source

pub fn skip_3(&mut self)

Advances the cursor to skip 3 bits

source

pub fn skip_4(&mut self)

Advances the cursor to skip 4 bits

source

pub fn skip_5(&mut self)

Advances the cursor to skip 5 bits

source

pub fn skip_6(&mut self)

Advances the cursor to skip 6 bits

source

pub fn skip_7(&mut self)

Advances the cursor to skip 7 bits

source

pub fn skip_8(&mut self)

Advances the cursor to skip 8 bits

source

pub fn skip_9(&mut self)

Advances the cursor to skip 9 bits

source

pub fn skip_10(&mut self)

Advances the cursor to skip 10 bits

source

pub fn skip_11(&mut self)

Advances the cursor to skip 11 bits

source

pub fn skip_12(&mut self)

Advances the cursor to skip 12 bits

source

pub fn skip_13(&mut self)

Advances the cursor to skip 13 bits

source

pub fn skip_14(&mut self)

Advances the cursor to skip 14 bits

source

pub fn skip_15(&mut self)

Advances the cursor to skip 15 bits

source

pub fn skip_16(&mut self)

Advances the cursor to skip 16 bits

source

pub fn skip_17(&mut self)

Advances the cursor to skip 17 bits

source

pub fn skip_18(&mut self)

Advances the cursor to skip 18 bits

source

pub fn skip_19(&mut self)

Advances the cursor to skip 19 bits

source

pub fn skip_20(&mut self)

Advances the cursor to skip 20 bits

source

pub fn skip_21(&mut self)

Advances the cursor to skip 21 bits

source

pub fn skip_22(&mut self)

Advances the cursor to skip 22 bits

source

pub fn skip_23(&mut self)

Advances the cursor to skip 23 bits

source

pub fn skip_24(&mut self)

Advances the cursor to skip 24 bits

source

pub fn skip_25(&mut self)

Advances the cursor to skip 25 bits

source

pub fn skip_26(&mut self)

Advances the cursor to skip 26 bits

source

pub fn skip_27(&mut self)

Advances the cursor to skip 27 bits

source

pub fn skip_28(&mut self)

Advances the cursor to skip 28 bits

source

pub fn skip_29(&mut self)

Advances the cursor to skip 29 bits

source

pub fn skip_30(&mut self)

Advances the cursor to skip 30 bits

source

pub fn skip_31(&mut self)

Advances the cursor to skip 31 bits

source

pub fn skip_32(&mut self)

Advances the cursor to skip 32 bits

source

pub fn skip_33(&mut self)

Advances the cursor to skip 33 bits

source

pub fn skip_34(&mut self)

Advances the cursor to skip 34 bits

source

pub fn skip_35(&mut self)

Advances the cursor to skip 35 bits

source

pub fn skip_36(&mut self)

Advances the cursor to skip 36 bits

source

pub fn skip_37(&mut self)

Advances the cursor to skip 37 bits

source

pub fn skip_38(&mut self)

Advances the cursor to skip 38 bits

source

pub fn skip_39(&mut self)

Advances the cursor to skip 39 bits

source

pub fn skip_40(&mut self)

Advances the cursor to skip 40 bits

source

pub fn skip_41(&mut self)

Advances the cursor to skip 41 bits

source

pub fn skip_42(&mut self)

Advances the cursor to skip 42 bits

source

pub fn skip_43(&mut self)

Advances the cursor to skip 43 bits

source

pub fn skip_44(&mut self)

Advances the cursor to skip 44 bits

source

pub fn skip_45(&mut self)

Advances the cursor to skip 45 bits

source

pub fn skip_46(&mut self)

Advances the cursor to skip 46 bits

source

pub fn skip_47(&mut self)

Advances the cursor to skip 47 bits

source

pub fn skip_48(&mut self)

Advances the cursor to skip 48 bits

source

pub fn skip_49(&mut self)

Advances the cursor to skip 49 bits

source

pub fn skip_50(&mut self)

Advances the cursor to skip 50 bits

source

pub fn skip_51(&mut self)

Advances the cursor to skip 51 bits

source

pub fn skip_52(&mut self)

Advances the cursor to skip 52 bits

source

pub fn skip_53(&mut self)

Advances the cursor to skip 53 bits

source

pub fn skip_54(&mut self)

Advances the cursor to skip 54 bits

source

pub fn skip_55(&mut self)

Advances the cursor to skip 55 bits

source

pub fn skip_56(&mut self)

Advances the cursor to skip 56 bits

source

pub fn skip_57(&mut self)

Advances the cursor to skip 57 bits

source

pub fn skip_58(&mut self)

Advances the cursor to skip 58 bits

source

pub fn skip_59(&mut self)

Advances the cursor to skip 59 bits

source

pub fn skip_60(&mut self)

Advances the cursor to skip 60 bits

source

pub fn skip_61(&mut self)

Advances the cursor to skip 61 bits

source

pub fn skip_62(&mut self)

Advances the cursor to skip 62 bits

source

pub fn skip_63(&mut self)

Advances the cursor to skip 63 bits

source

pub fn skip_64(&mut self)

Advances the cursor to skip 64 bits

Auto Trait Implementations§

§

impl<'b> RefUnwindSafe for WriteCursor<'b>

§

impl<'b> Send for WriteCursor<'b>

§

impl<'b> Sync for WriteCursor<'b>

§

impl<'b> Unpin for WriteCursor<'b>

§

impl<'b> !UnwindSafe for WriteCursor<'b>

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.