blart

Struct ConcatTuple

Source
pub struct ConcatTuple<M>(PhantomData<M>);
Expand description

This type implements a BytesMapping for tuples of types, concatenating their byte representations together.

The M type parameter also takes a tuple, the same size as the input, which contains types also implementing BytesMapping. Each type in this tuple is used to transform the corresponding value in the input tuple.

§Examples

Here is a basic example using the Identity transform for both tuple elements:

use blart::{ConcatTuple, AsBytes, Mapped, Identity};

let c1 = b"aaa";
let c2 = b"bb";

let t = Mapped::<ConcatTuple<(Identity, Identity)>, _>::new((*c1, *c2));

assert_eq!(t.as_bytes(), b"aaabb");

Here is a more complex example:

use std::net::Ipv4Addr;
use std::num::NonZeroI16;
use blart::{ConcatTuple, AsBytes, Mapped, ToOctets, ToIBE};

let c1 = NonZeroI16::new(256).unwrap();
let c2 = Ipv4Addr::LOCALHOST;

assert_eq!(Mapped::<ToIBE, _>::new(c1).as_bytes(), &[129, 0][..]);
assert_eq!(Mapped::<ToOctets, _>::new(c2).as_bytes(), &[127, 0, 0, 1][..]);

let t = Mapped::<ConcatTuple<(ToIBE, ToOctets)>, _>::new((c1, c2));

assert_eq!(t.as_bytes(), &[129, 0, 127, 0, 0, 1][..]);

Tuple Fields§

§0: PhantomData<M>

Trait Implementations§

Source§

impl<T0, MT0, T1, MT1, const LEN_T0: usize, const LEN_T1: usize> BytesMapping<(T0, T1)> for ConcatTuple<(MT0, MT1)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize> BytesMapping<(T0, T1, T2)> for ConcatTuple<(MT0, MT1, MT2)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1, T2)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize> BytesMapping<(T0, T1, T2, T3)> for ConcatTuple<(MT0, MT1, MT2, MT3)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2, T3)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1, T2, T3)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, T4, MT4, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize, const LEN_T4: usize> BytesMapping<(T0, T1, T2, T3, T4)> for ConcatTuple<(MT0, MT1, MT2, MT3, MT4)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>, MT4: BytesMapping<T4, Bytes = [u8; LEN_T4]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2, T3, T4)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1, T2, T3, T4)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, T4, MT4, T5, MT5, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize, const LEN_T4: usize, const LEN_T5: usize> BytesMapping<(T0, T1, T2, T3, T4, T5)> for ConcatTuple<(MT0, MT1, MT2, MT3, MT4, MT5)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>, MT4: BytesMapping<T4, Bytes = [u8; LEN_T4]>, MT5: BytesMapping<T5, Bytes = [u8; LEN_T5]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2, T3, T4, T5)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1, T2, T3, T4, T5)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, T4, MT4, T5, MT5, T6, MT6, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize, const LEN_T4: usize, const LEN_T5: usize, const LEN_T6: usize> BytesMapping<(T0, T1, T2, T3, T4, T5, T6)> for ConcatTuple<(MT0, MT1, MT2, MT3, MT4, MT5, MT6)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>, MT4: BytesMapping<T4, Bytes = [u8; LEN_T4]>, MT5: BytesMapping<T5, Bytes = [u8; LEN_T5]>, MT6: BytesMapping<T6, Bytes = [u8; LEN_T6]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2, T3, T4, T5, T6)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1, T2, T3, T4, T5, T6)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, T4, MT4, T5, MT5, T6, MT6, T7, MT7, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize, const LEN_T4: usize, const LEN_T5: usize, const LEN_T6: usize, const LEN_T7: usize> BytesMapping<(T0, T1, T2, T3, T4, T5, T6, T7)> for ConcatTuple<(MT0, MT1, MT2, MT3, MT4, MT5, MT6, MT7)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>, MT4: BytesMapping<T4, Bytes = [u8; LEN_T4]>, MT5: BytesMapping<T5, Bytes = [u8; LEN_T5]>, MT6: BytesMapping<T6, Bytes = [u8; LEN_T6]>, MT7: BytesMapping<T7, Bytes = [u8; LEN_T7]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2, T3, T4, T5, T6, T7)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1, T2, T3, T4, T5, T6, T7)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, T4, MT4, T5, MT5, T6, MT6, T7, MT7, T8, MT8, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize, const LEN_T4: usize, const LEN_T5: usize, const LEN_T6: usize, const LEN_T7: usize, const LEN_T8: usize> BytesMapping<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> for ConcatTuple<(MT0, MT1, MT2, MT3, MT4, MT5, MT6, MT7, MT8)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>, MT4: BytesMapping<T4, Bytes = [u8; LEN_T4]>, MT5: BytesMapping<T5, Bytes = [u8; LEN_T5]>, MT6: BytesMapping<T6, Bytes = [u8; LEN_T6]>, MT7: BytesMapping<T7, Bytes = [u8; LEN_T7]>, MT8: BytesMapping<T8, Bytes = [u8; LEN_T8]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2, T3, T4, T5, T6, T7, T8)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, T4, MT4, T5, MT5, T6, MT6, T7, MT7, T8, MT8, T9, MT9, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize, const LEN_T4: usize, const LEN_T5: usize, const LEN_T6: usize, const LEN_T7: usize, const LEN_T8: usize, const LEN_T9: usize> BytesMapping<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> for ConcatTuple<(MT0, MT1, MT2, MT3, MT4, MT5, MT6, MT7, MT8, MT9)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>, MT4: BytesMapping<T4, Bytes = [u8; LEN_T4]>, MT5: BytesMapping<T5, Bytes = [u8; LEN_T5]>, MT6: BytesMapping<T6, Bytes = [u8; LEN_T6]>, MT7: BytesMapping<T7, Bytes = [u8; LEN_T7]>, MT8: BytesMapping<T8, Bytes = [u8; LEN_T8]>, MT9: BytesMapping<T9, Bytes = [u8; LEN_T9]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes(bytes: Self::Bytes) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, T4, MT4, T5, MT5, T6, MT6, T7, MT7, T8, MT8, T9, MT9, T10, MT10, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize, const LEN_T4: usize, const LEN_T5: usize, const LEN_T6: usize, const LEN_T7: usize, const LEN_T8: usize, const LEN_T9: usize, const LEN_T10: usize> BytesMapping<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for ConcatTuple<(MT0, MT1, MT2, MT3, MT4, MT5, MT6, MT7, MT8, MT9, MT10)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>, MT4: BytesMapping<T4, Bytes = [u8; LEN_T4]>, MT5: BytesMapping<T5, Bytes = [u8; LEN_T5]>, MT6: BytesMapping<T6, Bytes = [u8; LEN_T6]>, MT7: BytesMapping<T7, Bytes = [u8; LEN_T7]>, MT8: BytesMapping<T8, Bytes = [u8; LEN_T8]>, MT9: BytesMapping<T9, Bytes = [u8; LEN_T9]>, MT10: BytesMapping<T10, Bytes = [u8; LEN_T10]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes(value: (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes( bytes: Self::Bytes, ) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

Convert the bytestring type back into the domain type
Source§

impl<T0, MT0, T1, MT1, T2, MT2, T3, MT3, T4, MT4, T5, MT5, T6, MT6, T7, MT7, T8, MT8, T9, MT9, T10, MT10, T11, MT11, const LEN_T0: usize, const LEN_T1: usize, const LEN_T2: usize, const LEN_T3: usize, const LEN_T4: usize, const LEN_T5: usize, const LEN_T6: usize, const LEN_T7: usize, const LEN_T8: usize, const LEN_T9: usize, const LEN_T10: usize, const LEN_T11: usize> BytesMapping<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> for ConcatTuple<(MT0, MT1, MT2, MT3, MT4, MT5, MT6, MT7, MT8, MT9, MT10, MT11)>
where MT0: BytesMapping<T0, Bytes = [u8; LEN_T0]>, MT1: BytesMapping<T1, Bytes = [u8; LEN_T1]>, MT2: BytesMapping<T2, Bytes = [u8; LEN_T2]>, MT3: BytesMapping<T3, Bytes = [u8; LEN_T3]>, MT4: BytesMapping<T4, Bytes = [u8; LEN_T4]>, MT5: BytesMapping<T5, Bytes = [u8; LEN_T5]>, MT6: BytesMapping<T6, Bytes = [u8; LEN_T6]>, MT7: BytesMapping<T7, Bytes = [u8; LEN_T7]>, MT8: BytesMapping<T8, Bytes = [u8; LEN_T8]>, MT9: BytesMapping<T9, Bytes = [u8; LEN_T9]>, MT10: BytesMapping<T10, Bytes = [u8; LEN_T10]>, MT11: BytesMapping<T11, Bytes = [u8; LEN_T11]>,

Source§

type Bytes = Box<[u8]>

The bytestring type that the D is converted to.
Source§

fn to_bytes( value: (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11), ) -> Self::Bytes

Convert the domain type into the bytestring type
Source§

fn from_bytes( bytes: Self::Bytes, ) -> (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Convert the bytestring type back into the domain type
Source§

impl<M: Debug> Debug for ConcatTuple<M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M> Freeze for ConcatTuple<M>

§

impl<M> RefUnwindSafe for ConcatTuple<M>
where M: RefUnwindSafe,

§

impl<M> Send for ConcatTuple<M>
where M: Send,

§

impl<M> Sync for ConcatTuple<M>
where M: Sync,

§

impl<M> Unpin for ConcatTuple<M>
where M: Unpin,

§

impl<M> UnwindSafe for ConcatTuple<M>
where M: 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.