Skip to main content

Protocol

Trait Protocol 

Source
pub trait Protocol {
    // Required methods
    fn discover(&self) -> Vec<u8> ;
    fn discovery_reply(&self, frame: &[u8]) -> Option<DiscoveryInfo>;
    fn row(
        &self,
        buf: &mut Vec<u8>,
        row: u16,
        x: u16,
        rgb: &[[u8; 3]],
        order: ColorOrder,
    );
    fn latch(&self, brightness: u8) -> Vec<u8> ;
    fn brightness(&self, brightness: u8) -> Vec<u8> ;
    fn flash_read(&self, index: u16, page: u16) -> Vec<u8> ;
    fn flash_reply<'a>(&self, frame: &'a [u8]) -> Option<&'a [u8]>;
    fn flash_write(
        &self,
        map: &FlashMap,
        index: u16,
        block: u8,
        page: u8,
        data: &[u8],
    ) -> Result<Vec<u8>, WriteError>;
    fn eeprom_write(&self, addr: u16, data: &[u8]) -> Vec<u8> ;
}
Expand description

One vendor’s wire protocol as frame builders and reply parsers, the surface ops drives a card through.

Colorlight is the only implementation; a second vendor implements this in its own crate (docs/cards.md). Sequencing and sockets stay with the caller.

Required Methods§

Source

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

The discovery request.

Source

fn discovery_reply(&self, frame: &[u8]) -> Option<DiscoveryInfo>

The card a discovery reply describes, if frame is one.

Source

fn row( &self, buf: &mut Vec<u8>, row: u16, x: u16, rgb: &[[u8; 3]], order: ColorOrder, )

One row packet into buf: screen row row, pixels from x.

Source

fn latch(&self, brightness: u8) -> Vec<u8>

The latch frame that applies the rows sent since the last one.

Source

fn brightness(&self, brightness: u8) -> Vec<u8>

The brightness frame sent before the rows.

Source

fn flash_read(&self, index: u16, page: u16) -> Vec<u8>

Read one chunk of flash at a 256-byte page index.

Source

fn flash_reply<'a>(&self, frame: &'a [u8]) -> Option<&'a [u8]>

The flash bytes a reply carries, if frame is a flash reply.

Source

fn flash_write( &self, map: &FlashMap, index: u16, block: u8, page: u8, data: &[u8], ) -> Result<Vec<u8>, WriteError>

Write one page of the parameter block; refused outside map.

§Errors

Refuses a block outside the map or a payload that is not one page.

Source

fn eeprom_write(&self, addr: u16, data: &[u8]) -> Vec<u8>

Write one EEPROM record at its own address and length.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§