Trait xcb::Wired[][src]

pub trait Wired {
    type Params: Copy;
    unsafe fn compute_wire_len(ptr: *const u8, params: Self::Params) -> usize;
fn wire_len(&self) -> usize;
fn serialize(&self, wire_buf: &mut [u8]) -> usize; }
Expand description

Trait for types that can serialize themselves over the X wire.

This trait is used internally for requests serialization, or in some accessors that have to compute the size of some wire data.

Associated Types

type to external context necessary to compute the length

Required methods

Compute the length of serialized data of an instance starting by ptr.

Safety

This function is highly unsafe as the pointer must point to data that is a valid wired representation of Self. Failure to respect this will lead to reading of invalid memory.

Compute the length of wired serialized data of self

Serialize self over the X wire and returns how many bytes were written.

wire_buf must be larger or as long as the value returned by wire_len. serialize MUST write the data in its entirety at once, at the begining of wire_buf. That is, it returns the same value as wire_len. The interest in returning the value is that it is easy to compute in serialize and allow to easily chain serialization of fields in a struct.

Panics

Panics if wire_buf is too small to contain the serialized representation of self.

Implementations on Foreign Types

Implementors