[][src]Trait secded::SecDedCodec

pub trait SecDedCodec {
    fn encodable_size(&self) -> usize;
fn code_size(&self) -> usize;
fn encode(&self, data: &mut [u8]);
fn decode(&self, data: &mut [u8]) -> Result<(), ()>; fn expected_slice_size(&self) -> Option<usize> { ... } }

Your main interaction point with this crate, it allows you to encode and decode your data slices.

Required methods

fn encodable_size(&self) -> usize

Returns the number of bits that this SecDedCodec can encode.

fn code_size(&self) -> usize

Returns the size of the correction code that will be appended to the data.

fn encode(&self, data: &mut [u8])

Encodes the data IN-PLACE

Arguments:

  • data: The slice of data to encode. The last secded.code_size() bits MUST be set to 0.

Panics:

Depending on the implementation, panics may occur if the size of the slice isn't adapted to the Codec:

  • SecDed64 panics if data.len() != 8
  • SecDed128 panics if data.len() != 16
  • You can use secded.expected_slice_size() to find out if a specific size is required for the slice.

Unless you use the no-panics feature, encoding will also panic if the data you try to encode has some bits set to 1 in the reserved space, or past the encodable_size() + code_size() rightmost bits

fn decode(&self, data: &mut [u8]) -> Result<(), ()>

Decodes the data IN-PLACE

Arguments:

  • data: The slice of data to decode.
    The last secded.code_size() bits will be reset to 0, a single error will be corrected implicitly.

Returns:

Ok(()) if the data slice's correctness has been checked: 0 error found or 1 found and corrected. Err(()) if 2 errors were detected.

Panics:

Depending on the implementation, panics may occur if the size of the slice isn't adapted to the Codec:

  • SecDed64 panics if data.len() != 8
  • SecDed128 panics if data.len() != 16
  • You can use secded.expected_slice_size() to find out if a specific size is required for the slice.
Loading content...

Provided methods

fn expected_slice_size(&self) -> Option<usize>

Returns Some(size) if the implementation would panic if data.len() != size

Loading content...

Implementors

impl SecDedCodec for SecDed128[src]

fn encode(&self, buffer: &mut [u8])[src]

Encodes the data IN-PLACE

Arguments:

  • data: The slice of data to encode. The last secded.code_size() bits MUST be set to 0.

Panics:

Panics if data.len() != 16

Unless you use the no-panics feature, encoding will also panic if the data you try to encode has some bits set to 1 in the reserved space, or past the encodable_size() + code_size() rightmost bits

fn decode(&self, buffer: &mut [u8]) -> Result<(), ()>[src]

Decodes the data IN-PLACE

Arguments:

  • data: The slice of data to decode.
    The last secded.code_size() bits will be reset to 0, a single error will be corrected implicitly.

Returns:

Ok(()) if the data slice's correctness has been checked: 0 error found or 1 found and corrected. Err(()) if 2 errors were detected.

Panics:

Panics if data.len() != 16

impl SecDedCodec for SecDed64[src]

fn encode(&self, buffer: &mut [u8])[src]

Encodes the data IN-PLACE

Arguments:

  • data: The slice of data to encode. The last secded.code_size() bits MUST be set to 0.

Panics:

Panics if data.len() != 8

Unless you use the no-panics feature, encoding will also panic if the data you try to encode has some bits set to 1 in the reserved space, or past the encodable_size() + code_size() rightmost bits

fn decode(&self, buffer: &mut [u8]) -> Result<(), ()>[src]

Decodes the data IN-PLACE

Arguments:

  • data: The slice of data to decode.
    The last secded.code_size() bits will be reset to 0, a single error will be corrected implicitly.

Returns:

Ok(()) if the data slice's correctness has been checked: 0 error found or 1 found and corrected. Err(()) if 2 errors were detected.

Panics:

Panics if data.len() != 8

Loading content...