pub struct Array(/* private fields */);
Expand description

Wrapper around the array data provided by the wayland wire format.

On the wire, wl_array arguments are simple byte arrays. Protocol documentation may specify a specific interpretation of the bytes, however this is not directly modeled in the protocol XML.

For example, the wl_keyboard::enter event has an argument for the set of keys pressed at the time of the event:

While not explitly stated, |keys| is an array of |uint| arguments. These are packed into the array using the same rules used to write consecutive |uint| arguments to a Message.

Implementations§

source§

impl Array

source

pub fn new() -> Self

Creates a new, empty Array.

source

pub fn from_vec(v: Vec<u8>) -> Self

Creates a new Array that contains the bytes stored in the provided Vec.

source

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

Access the array data as a slice.

source

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

Extracts the Array data as a Vec.

source

pub fn len(&self) -> usize

Returns the length (in bytes) of the array.

source

pub fn push<T: Into<Arg>>(&mut self, arg: T) -> Result<()>

Writes an Arg to the end of this Array, increasing its size.

Note that arrays cannot contain handles and it is an error to attempt to write an Arg::Handle to an array.

source

pub fn read_arg(&mut self, kind: ArgKind) -> Result<Arg>

Reads an Arg out of this Array and return the value.

Note that arrays cannot contain handles and it is an error to attempt to read an ArgKind::Handle from an array.

Trait Implementations§

source§

impl Debug for Array

source§

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

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

impl From<Array> for Arg

source§

fn from(v: Array) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8>> for Array

source§

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

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Array

§

impl RefUnwindSafe for Array

§

impl Send for Array

§

impl Sync for Array

§

impl Unpin for Array

§

impl UnwindSafe for Array

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>,

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V