Struct SmlReaderBuilder

Source
pub struct SmlReaderBuilder<Buf: Buffer> { /* private fields */ }
Expand description

Builder struct for SmlReader that allows configuring the internal buffer type.

See here for an explanation of the different internal buffer types and how to use the builder to customize them.

Implementations§

Source§

impl<Buf: Buffer> SmlReaderBuilder<Buf>

Source

pub fn from_reader<R: Read>(self, reader: R) -> SmlReader<IoReader<R>, Buf>

Available on crate feature std only.

Build an SmlReader from a type implementing std::io::Read.

This function is available only if sml-rs is built with the "std" feature.

§Examples
let data = [1, 2, 3];
let cursor = std::io::Cursor::new(data);  // implements std::io::Read
let reader = SmlReader::with_static_buffer::<1024>().from_reader(cursor);
Source

pub fn from_eh_reader<R: Read<u8, Error = E>, E>( self, reader: R, ) -> SmlReader<EhReader<R, E>, Buf>

Available on crate feature embedded_hal only.

Build an SmlReader from a type implementing embedded_hal::serial::Read<u8>.

This function is available only if sml-rs is built with the "embedded-hal" feature.

§Examples
// usually provided by hardware abstraction layers (HALs) for specific chips
// let pin = ...;

let reader = SmlReader::with_static_buffer::<1024>().from_eh_reader(pin);
Source

pub fn from_slice(self, reader: &[u8]) -> SmlReader<SliceReader<'_>, Buf>

Build an SmlReader from a slice of bytes.

§Examples
let data: &[u8] = &[1, 2, 3];
let reader = SmlReader::with_static_buffer::<1024>().from_slice(data);
Source

pub fn from_iterator<B, I>( self, iter: I, ) -> SmlReader<IterReader<I::IntoIter, B>, Buf>
where I: IntoIterator<Item = B>, B: Borrow<u8>,

Build an SmlReader from a type that can be turned into a byte iterator.

§Examples
let data: [u8; 3] = [1, 2, 3];
let builder = SmlReader::with_static_buffer::<1024>();
let reader = builder.clone().from_iterator(data.clone());      // [u8; 3]
let reader = builder.clone().from_iterator(&data);             // &[u8; 3]
let reader = builder.clone().from_iterator(data.as_slice());   // &[u8]
let reader = builder.clone().from_iterator(data.iter());       // impl Iterator<Item = &u8>
let reader = builder.clone().from_iterator(data.into_iter());  // impl Iterator<Item = u8>

Trait Implementations§

Source§

impl<Buf: Buffer> Clone for SmlReaderBuilder<Buf>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<Buf> Freeze for SmlReaderBuilder<Buf>

§

impl<Buf> RefUnwindSafe for SmlReaderBuilder<Buf>
where Buf: RefUnwindSafe,

§

impl<Buf> Send for SmlReaderBuilder<Buf>
where Buf: Send,

§

impl<Buf> Sync for SmlReaderBuilder<Buf>
where Buf: Sync,

§

impl<Buf> Unpin for SmlReaderBuilder<Buf>
where Buf: Unpin,

§

impl<Buf> UnwindSafe for SmlReaderBuilder<Buf>
where Buf: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.