Skip to main content

CesrCode

Trait CesrCode 

Source
pub trait CesrCode:
    Sealed
    + Copy
    + Eq
    + Debug {
    // Required methods
    fn to_matter_code(&self) -> MatterCode;
    fn as_str(&self) -> &'static str;

    // Provided methods
    fn get_sizage(&self) -> Sizage { ... }
    fn raw_size(&self) -> Result<usize, ValidationError> { ... }
    fn placeholder(&self) -> Result<String, ValidationError> { ... }
}
Available on crate feature core only.
Expand description

Sealed trait that all CESR typed codes must implement.

Provides the ability to convert to the untyped MatterCode, retrieve the Base64 string representation, and look up the Sizage and raw byte size.

Required Methods§

Source

fn to_matter_code(&self) -> MatterCode

Converts this typed code to the untyped MatterCode.

Source

fn as_str(&self) -> &'static str

Returns the canonical Base64 string representation of this code.

Provided Methods§

Source

fn get_sizage(&self) -> Sizage

Returns the Sizage descriptor for this code.

Source

fn raw_size(&self) -> Result<usize, ValidationError>

Returns the expected raw byte size for this code.

§Errors

Returns a ValidationError for variable-size codes.

Source

fn placeholder(&self) -> Result<String, ValidationError>

Available on crate feature alloc only.

Returns a placeholder qb64 string of this code’s full character width, filled with DUMMY_CHAR.

Reserves a self-addressing field’s exact byte span before its digest is computed and back-patched over the placeholder. The width equals the code’s fixed full size (fs).

§Errors

Returns ValidationError::InvalidSizingOperation for variable-size codes, which have no fixed placeholder width.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§