Trait kernel::hil::crc::Crc

source ·
pub trait Crc<'a> {
    // Required methods
    fn set_client(&self, client: &'a dyn Client);
    fn algorithm_supported(&self, algorithm: CrcAlgorithm) -> bool;
    fn set_algorithm(&self, algorithm: CrcAlgorithm) -> Result<(), ErrorCode>;
    fn input(
        &self,
        data: SubSliceMut<'static, u8>,
    ) -> Result<(), (ErrorCode, SubSliceMut<'static, u8>)>;
    fn compute(&self) -> Result<(), ErrorCode>;
    fn disable(&self);
}

Required Methods§

source

fn set_client(&self, client: &'a dyn Client)

Set the client to be used for callbacks of the CRC implementation.

source

fn algorithm_supported(&self, algorithm: CrcAlgorithm) -> bool

Check whether a given CRC algorithm is supported by a CRC implementation.

Returns true if the algorithm specified is supported.

source

fn set_algorithm(&self, algorithm: CrcAlgorithm) -> Result<(), ErrorCode>

Set the CRC algorithm to use.

Calling this method may enable the CRC engine in case of a physical unit.

If the device is currently processing a chunk of data or calculating a CRC, this operation will be refused, returning ErrorCode::BUSY. If a CRC calculation currently has pending data, it will be cancelled and the CRC engine’s state reset.

ErrorCode::NOSUPPORT will be returned if the algorithm requested is not supported. To non-invasively check whether a given algorithm is supported by a CRC implementation, use Crc::algorithm_supported.

source

fn input( &self, data: SubSliceMut<'static, u8>, ) -> Result<(), (ErrorCode, SubSliceMut<'static, u8>)>

Input chunked data into the CRC implementation.

Calling this method may enable the CRC engine in case of a physical unit.

If Crc::set_algorithm has not been invoked before, this method must return ErrorCode::RESERVE.

If the device is currently already processing a chunk of data or calculating a CRC, ErrorCode::BUSY must be returned.

After the chunk of data has been processed, Client::input_done is called.

The implementation may only read a part of the passed SubSliceMut. It will return the bytes read and will resize the returned SubSliceMut appropriately prior to passing it back through Client::input_done.

source

fn compute(&self) -> Result<(), ErrorCode>

Request calculation of the CRC.

Calling this method may enable the CRC engine in case of a physical unit.

If Crc::set_algorithm has not been invoked before, this method must return ErrorCode::RESERVE.

If the device is currently processing a chunk of data or calculating a CRC, ErrorCode::BUSY must be returned.

After the CRC has been calculated, Client::crc_done is called.

source

fn disable(&self)

Disable the CRC unit until susequent calls to methods which will enable the CRC unit again.

Implementors§