pub struct RawVec<T>(pub Vec<T>);
Expand description

This struct represents the concrete type of a vector, that is, vector as opposed to the type Vector. This bare type is less common, so instead of creating a enum for Vector wrapping vector as Rust’s Vec (as we would do with auto-generated code), a new-type for vector is used instead.

Tuple Fields§

§0: Vec<T>

Trait Implementations§

source§

impl<T: Clone> Clone for RawVec<T>

source§

fn clone(&self) -> RawVec<T>

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
source§

impl<T: Debug> Debug for RawVec<T>

source§

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

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

impl<T: Deserializable> Deserializable for RawVec<T>

source§

fn deserialize(buf: Buffer<'_, '_>) -> Result<Self>

Deserializes a vector of deserializable items according to the following definition:

  • vector#1cb5c415 {t:Type} # [ t ] = Vector t;.
Examples
use grammers_tl_types::{RawVec, Deserializable};

assert_eq!(RawVec::<i32>::from_bytes(&[0x0, 0x0, 0x0, 0x0]).unwrap().0, Vec::<i32>::new());
assert_eq!(RawVec::<i32>::from_bytes(&[0x1, 0x0, 0x0, 0x0, 0x7f, 0x0, 0x0, 0x0]).unwrap().0, vec![0x7f_i32]);
source§

fn from_bytes(buf: &[u8]) -> Result<Self>where Self: Sized,

Convenience function to deserialize an instance from a given buffer. Read more
source§

impl<T: PartialEq> PartialEq for RawVec<T>

source§

fn eq(&self, other: &RawVec<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Serializable> Serializable for RawVec<T>

source§

fn serialize(&self, buf: Buffer<'_>)

Serializes a raw vector of serializable items according to the following definition:

  • vector#1cb5c415 {t:Type} # [ t ] = Vector t;.
Examples
use grammers_tl_types::{RawVec, Serializable};

assert_eq!(RawVec(Vec::<i32>::new()).to_bytes(), [0x0, 0x0, 0x0, 0x0]);
assert_eq!(RawVec(vec![0x7f_i32]).to_bytes(), [0x1, 0x0, 0x0, 0x0, 0x7f, 0x0, 0x0, 0x0]);
source§

fn to_bytes(&self) -> Vec<u8>

Convenience function to serialize the object into a new buffer and return its bytes. It is more efficient to reuse a existing buffer with Serializable::serialize.
source§

impl<T> StructuralPartialEq for RawVec<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for RawVec<T>where T: RefUnwindSafe,

§

impl<T> Send for RawVec<T>where T: Send,

§

impl<T> Sync for RawVec<T>where T: Sync,

§

impl<T> Unpin for RawVec<T>where T: Unpin,

§

impl<T> UnwindSafe for RawVec<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.