Trait const_writer::ConstWriterAdapter[][src]

pub trait ConstWriterAdapter {
    unsafe fn write<const N: usize>(self, value: &[u8; N]) -> Self;
unsafe fn grow<const M: usize>(self) -> Self; }

Source of all performance of crate. Provide unsafe interface to underlying buffer.

Because const generics expressions in traits works really bad, this adapter doesn't has generic len param, so write is basically unchecked write to array. This adapter must be used within ConstWriter because it holds and tracks buffer length

Required methods

unsafe fn write<const N: usize>(self, value: &[u8; N]) -> Self[src]

Write bytes and advances inner buffer

Safety

Unsafe because with current const_generics and const_evaluatable_checked we can't define trait which returns self with calculated const generic param.

You should make sure that in total you advance less or equal than N bytes

unsafe fn grow<const M: usize>(self) -> Self[src]

Ensures that underlying buffer have space for M additional bytes

Example

If 5 bytes were written to buffer, then grow::<10>() will ensure that underlying buffer have capacity at least 15

Loading content...

Implementors

impl<'a> ConstWriterAdapter for VecWriterAdapter<'a>[src]

impl<'a, 'inner> ConstWriterAdapter for SliceWriterAdapter<'a, 'inner>[src]

Loading content...