pub trait Crc<'a> {
    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: LeasableMutableBuffer<'static, u8>
    ) -> Result<(), (ErrorCode, LeasableMutableBuffer<'static, u8>)>; fn compute(&self) -> Result<(), ErrorCode>; fn disable(&self); }

Required Methods

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

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

Returns true if the algorithm specified is supported.

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.

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 LeasableMutableBuffer. It will return the bytes read and will resize the returned LeasableMutableBuffer appropriately prior to passing it back through Client::input_done.

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.

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

Implementors