Trait compact_genome::interface::alphabet::AlphabetCharacter
source · pub trait AlphabetCharacter: Into<u8> + TryFrom<u8> {
const ALPHABET_SIZE: usize;
// Required methods
fn index(&self) -> usize;
fn from_index(index: usize) -> Result<Self, AlphabetError>;
fn from_index_ref(index: usize) -> Result<&'static Self, AlphabetError>;
fn complement(&self) -> Self;
}
Expand description
A character in an alphabet.
Required Associated Constants§
sourceconst ALPHABET_SIZE: usize
const ALPHABET_SIZE: usize
The amount of characters in the alphabet.
Required Methods§
sourcefn from_index(index: usize) -> Result<Self, AlphabetError>
fn from_index(index: usize) -> Result<Self, AlphabetError>
Constructs the character from the given index, returning None
if it is invalid.
sourcefn from_index_ref(index: usize) -> Result<&'static Self, AlphabetError>
fn from_index_ref(index: usize) -> Result<&'static Self, AlphabetError>
Constructs the character from the given index, returning None
if it is invalid.
This method returns a static reference to the character type, so it can only be implemented via lookup in a static table.
It is required to create an implementation of std::ops::Index for genome sequence types that do not store the characters in plain format.
sourcefn complement(&self) -> Self
fn complement(&self) -> Self
Constructs the complement of this character.