Trait OsdpFileOps

Source
pub trait OsdpFileOps {
    // Required methods
    fn open(&mut self, id: i32, read_only: bool) -> Result<usize, OsdpError>;
    fn offset_read(&self, buf: &mut [u8], off: u64) -> Result<usize, OsdpError>;
    fn offset_write(&self, buf: &[u8], off: u64) -> Result<usize, OsdpError>;
    fn close(&mut self) -> Result<(), OsdpError>;
}
Expand description

File operations handler trait. Any type that implements this trait can be registered with crate::ControlPanel::register_file_ops or crate::PeripheralDevice::register_file_ops.

Required Methods§

Source

fn open(&mut self, id: i32, read_only: bool) -> Result<usize, OsdpError>

Open a file, with pre-agreed File-ID [id]; returns the size of the file that was opened or crate::OsdpError::FileTransfer.

Source

fn offset_read(&self, buf: &mut [u8], off: u64) -> Result<usize, OsdpError>

Read bytes into buffer [buf] from offset [off] of the file; returns number of bytes read or crate::OsdpError::FileTransfer.

Source

fn offset_write(&self, buf: &[u8], off: u64) -> Result<usize, OsdpError>

Write bytes from buffer [buf] at offset [off] of the file; returns number of bytes written or crate::OsdpError::FileTransfer.

Source

fn close(&mut self) -> Result<(), OsdpError>

Close the currently open file; returns crate::OsdpError::FileTransfer if close failed.

Implementors§