Trait azul_peek_poke::Peek[][src]

pub trait Peek: Poke {
    unsafe fn peek_from(bytes: *const u8, output: *mut Self) -> *const u8;
Expand description

A trait for values that provide deserialization from buffers of bytes.


use peek_poke::Peek;

struct Bar {
    a: u32,
    b: u8,
    c: i16,


impl Peek for Bar {
    unsafe fn peek_from(&mut self, bytes: *const u8) -> *const u8 {
        let bytes = self.a.peek_from(bytes);
        let bytes = self.b.peek_from(bytes);


The Peek trait contains unsafe methods for the following reasons, and implementors must ensure that they adhere to these contracts:

  • Callers of this trait are expected to rely on the contract defined on each method, and implementors must ensure that peek_from() doesn’t read more bytes from bytes than is returned by Peek::max_size().

Required methods

Deserialize from the buffer pointed to by bytes.

Returns a pointer to the next byte after the unconsumed bytes not used to deserialize the representation of Self.


This function is unsafe because undefined behavior can result if the caller does not ensure all of the following:

  • bytes must denote a valid pointer to a block of memory.

  • bytes must pointer to at least the number of bytes returned by Poke::max_size().

Implementations on Foreign Types