pub struct AiidEncoding { /* private fields */ }Expand description
an instance that can encode / decode a particular aiid encoding configuration
Implementations§
Source§impl AiidEncoding
impl AiidEncoding
Sourcepub fn new(config: AiidEncodingConfig) -> AiidResult<Self>
pub fn new(config: AiidEncodingConfig) -> AiidResult<Self>
create a new AiidEncoding instance from given AiidEncodingConfig
Sourcepub fn with_kind(kind: &str) -> AiidResult<Self>
pub fn with_kind(kind: &str) -> AiidResult<Self>
create a new config given a kind token string
§Example
let aia0 = aingle_id::AiidEncoding::with_kind("aia0").unwrap();
let aik0 = aingle_id::AiidEncoding::with_kind("aik0").unwrap();
let ais0 = aingle_id::AiidEncoding::with_kind("ais0").unwrap();Sourcepub fn encode(&self, data: &[u8]) -> AiidResult<String>
pub fn encode(&self, data: &[u8]) -> AiidResult<String>
encode a string to base32 with this instance’s configuration
Sourcepub fn decode(&self, data: &str) -> AiidResult<Vec<u8>>
pub fn decode(&self, data: &str) -> AiidResult<Vec<u8>>
decode the data from a base32 string with this instance’s configuration. Reed-Solomon can correct up to 1/2 its parity size worth of erasures (if no other errors are present).
Sourcepub fn is_corrupt(&self, data: &str) -> AiidResult<bool>
pub fn is_corrupt(&self, data: &str) -> AiidResult<bool>
a lighter-weight check to determine if a base32 string is corrupt