Struct Bytes

Source
pub struct Bytes(/* private fields */);
Expand description

Wrapper around Vec of u8 used to store data in form of bytes in this library.

Implementations§

Source§

impl Bytes

Source

pub fn new(content: Vec<u8>) -> Self

Creates a new Bytes from content.

Source

pub fn empty() -> Self

Creates a new empty Bytes.

Usually declared as mutable and filled later.

Source

pub fn push(&mut self, value: u8)

Pushes a new u8 into Bytes.

Wrapper around Vec::push.

Source

pub fn as_slice(&self) -> &[u8]

Returns an immutable slice of bytes.

Source

pub fn vec(&self) -> Vec<u8>

Returns an inner Vec.

Vec is cloned.

Source

pub fn vec_ref(&self) -> &Vec<u8>

Returns an reference to inner Vec.

Source

pub fn vec_mut(&mut self) -> &mut Vec<u8>

Returns an mutable reference to inner Vec.

Source

pub fn into_vec(self) -> Vec<u8>

Takes an ownership of self and returns an inner Vec.

Source

pub fn len(&self) -> usize

Returns number of bytes inside Self.

Wrapper around Vec::len.

Source

pub fn is_empty(&self) -> bool

Returns if Self is empty.

Wrapper around Vec::is_empty.

Source

pub fn append(&mut self, other: &mut Bytes)

Moves all elements of other into Self, leaving other empty.

Wrapper around Vec::append.

Source

pub fn get(&self, index: usize) -> Option<u8>

Returns Some with u8 inside if there is a value on given index, otherwise returns None.

Source

pub fn find_pattern(&self, pattern: &Bytes) -> Option<Vec<usize>>

Returns indexes on which provided pattern starts.

Source

pub fn split_at_pat(self, pattern: &Bytes) -> Vec<Bytes>

Splits self at provided pattern which is not included in final result.

Trait Implementations§

Source§

impl Clone for Bytes

Source§

fn clone(&self) -> Bytes

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Bytes

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Bytes

Source§

fn default() -> Bytes

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Bytes

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Bytes

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<const L: usize> From<[u8; L]> for Bytes

Source§

fn from(value: [u8; L]) -> Self

Converts to this type from the input type.
Source§

impl From<DateTime<Utc>> for Bytes

Source§

fn from(value: DateTime<Utc>) -> Self

Converts to this type from the input type.
Source§

impl From<Packet> for Bytes

Source§

fn from(value: Packet) -> Self

Converts to this type from the input type.
Source§

impl From<PacketKind> for Bytes

Source§

fn from(value: PacketKind) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Bytes

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Bytes

Source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Bytes

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Bytes

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Bytes

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Bytes

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<u8> for Bytes

Source§

fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromRon<'_> for Bytes

Source§

fn from_ron(ron: &'a str) -> Result<Self, Error>

Creates an implementor from RON. Read more
Source§

impl<Idx> Index<Idx> for Bytes
where Idx: SliceIndex<[u8]>,

Source§

type Output = <Idx as SliceIndex<[u8]>>::Output

The returned type after indexing.
Source§

fn index(&self, index: Idx) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IntoIterator for Bytes

Source§

type Item = u8

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<Bytes as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Bytes

Source§

fn eq(&self, other: &Bytes) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Bytes

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToRon for Bytes

Source§

fn to_ron(&self) -> Result<String, Error>

Returns a RON from implementor. Read more
Source§

fn to_ron_pretty(&self, config: Option<PrettyConfig>) -> Result<String, Error>

Returns a pretty formatted RON from implementor. Read more
Source§

impl TryFrom<&Bytes> for DateTime<Utc>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Bytes> for Packet

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Bytes> for String

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Bytes> for u16

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Bytes> for u32

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Bytes> for u8

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Bytes> for usize

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for DateTime<Utc>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for Packet

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for PacketKind

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for String

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for u16

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for u32

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for u8

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for usize

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Bytes

Auto Trait Implementations§

§

impl Freeze for Bytes

§

impl RefUnwindSafe for Bytes

§

impl Send for Bytes

§

impl Sync for Bytes

§

impl Unpin for Bytes

§

impl UnwindSafe for Bytes

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,