Skip to main content

Crc

Trait 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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§