Struct Prefixed
pub struct Prefixed<P, T> {
prefix: P,
value: T,
}Expand description
A string or array with a length prefix of type P.
Decode Utf8Bytes or Bytes for strings and byte arrays, and
Items for other arrays. Encode borrowed values, such as &str or
&[T].
§Example
use ql_qmi::codec::{Encode, Prefixed, Reader, Utf8Bytes};
let mut out = Vec::new();
Prefixed::<u8, _>::new("228").unwrap().encode(&mut out);
assert_eq!(out, [3, b'2', b'2', b'8']);
let mcc: Prefixed<u8, Utf8Bytes> = Reader::new(out.into()).read().unwrap();
assert_eq!(mcc.get(), "228");Fields§
§prefix: P§value: TImplementations§
§impl<P: LengthPrefix, T: Sequence> Prefixed<P, T>
impl<P: LengthPrefix, T: Sequence> Prefixed<P, T>
§impl<P, T> Prefixed<P, T>
impl<P, T> Prefixed<P, T>
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the value.
Trait Implementations§
impl<P: Copy, T: Copy> Copy for Prefixed<P, T>
§impl<P: LengthPrefix> Decode for Prefixed<P, Bytes>
impl<P: LengthPrefix> Decode for Prefixed<P, Bytes>
§impl<P: LengthPrefix> Decode for Prefixed<P, Utf8Bytes>
impl<P: LengthPrefix> Decode for Prefixed<P, Utf8Bytes>
impl<P: Eq, T: Eq> Eq for Prefixed<P, T>
impl<P: PartialEq, T: PartialEq> StructuralPartialEq for Prefixed<P, T>
Auto Trait Implementations§
impl<P, T> Freeze for Prefixed<P, T>
impl<P, T> RefUnwindSafe for Prefixed<P, T>where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<P, T> Send for Prefixed<P, T>
impl<P, T> Sync for Prefixed<P, T>
impl<P, T> Unpin for Prefixed<P, T>
impl<P, T> UnsafeUnpin for Prefixed<P, T>where
P: UnsafeUnpin,
T: UnsafeUnpin,
impl<P, T> UnwindSafe for Prefixed<P, T>where
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more