Struct Sized

Source
pub struct Sized<T, S, F>(pub F, pub T)
where
    T: WriteInto,
    S: WriteInto,
    F: FnOnce(usize) -> S;
Expand description

Used to write values prepended with size of their representation.

§Example

use write_into::{Sized, Plain, Uleb128, write_into};

let mut buffer = Vec::new();
let written = write_into(&mut buffer, Sized(Uleb128, Plain("Hello, Sailor!"))).unwrap();
assert_eq!(written, 14);
assert_eq!(&buffer, b"\x0EHello, Sailor!");

Tuple Fields§

§0: F§1: T

Trait Implementations§

Source§

impl<T, S, F> WriteInto for &Sized<T, S, F>
where T: Copy + WriteInto, S: WriteInto, F: Copy + FnOnce(usize) -> S,

Returns how many bytes was taken by the representation of T.

Source§

type Output = usize

Result of WriteInto::write_into function (e.g. () or usize).
Source§

fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>

Writes value into I/O sink.
Source§

impl<T, S, F> WriteInto for Sized<T, S, F>
where T: WriteInto, S: WriteInto, F: FnOnce(usize) -> S,

Returns how many bytes was taken by the representation of T.

Source§

type Output = usize

Result of WriteInto::write_into function (e.g. () or usize).
Source§

fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>

Writes value into I/O sink.

Auto Trait Implementations§

§

impl<T, S, F> Freeze for Sized<T, S, F>
where F: Freeze, T: Freeze,

§

impl<T, S, F> RefUnwindSafe for Sized<T, S, F>

§

impl<T, S, F> Send for Sized<T, S, F>
where F: Send, T: Send,

§

impl<T, S, F> Sync for Sized<T, S, F>
where F: Sync, T: Sync,

§

impl<T, S, F> Unpin for Sized<T, S, F>
where F: Unpin, T: Unpin,

§

impl<T, S, F> UnwindSafe for Sized<T, S, F>
where F: UnwindSafe, T: 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> 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, 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.