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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

  • vector#1cb5c415 {t:Type} # [ t ] = Vector t;.
Examples
use gramme_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]);

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

  • vector#1cb5c415 {t:Type} # [ t ] = Vector t;.
Examples
use gramme_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]);

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. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.