[−][src]Trait secded::SecDedCodec
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 lastsecded.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 lastsecded.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.
Provided methods
fn expected_slice_size(&self) -> Option<usize>
Returns Some(size)
if the implementation would panic if data.len() != size
Implementors
impl SecDedCodec for SecDed128
[src]
fn encodable_size(&self) -> usize
[src]
fn code_size(&self) -> usize
[src]
fn expected_slice_size(&self) -> Option<usize>
[src]
fn encode(&self, buffer: &mut [u8])
[src]
Encodes the data IN-PLACE
Arguments:
data
: The slice of data to encode. The lastsecded.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 lastsecded.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 encodable_size(&self) -> usize
[src]
fn code_size(&self) -> usize
[src]
fn expected_slice_size(&self) -> Option<usize>
[src]
fn encode(&self, buffer: &mut [u8])
[src]
Encodes the data IN-PLACE
Arguments:
data
: The slice of data to encode. The lastsecded.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 lastsecded.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