Skip to main content

Canonicalizer

Struct Canonicalizer 

Source
pub struct Canonicalizer { /* private fields */ }
Expand description

Provides deterministic canonicalization and hashing of content Implements explicit v1 algorithms for YAML and Markdown canonicalization

Implementations§

Source§

impl Canonicalizer

Source

pub fn new() -> Canonicalizer

Create a new canonicalizer with the current version

Source

pub fn version(&self) -> &str

Get the canonicalization version string

Source

pub const fn backend(&self) -> &'static str

Get the canonicalization backend identifier

Source

pub fn canonicalize_yaml(&self, content: &str) -> Result<String, Error>

Canonicalize YAML content (v1 algorithm) Uses JCS (JSON Canonicalization Scheme) approach:

  1. Parse YAML → convert to JSON with deterministic maps (BTreeMap)

  2. Keep human-readable YAML on disk (normalized: LF, trim trailing spaces, final newline)

  3. For hashing: use JCS canonicalization of the JSON representation

    Reserved for future content-addressed verification

Source

pub fn normalize_markdown(&self, content: &str) -> Result<String, Error>

Normalize Markdown content (v1 algorithm) Explicit rules:

  1. Normalize \n, trim trailing spaces, collapse trailing blank lines to 1
  2. Fence normalization: ``` with language tag preserved
  3. Final newline enforced
  4. Normalize heading underlines to # style
  5. Stable ordering where structure allows
Source

pub fn normalize_text(&self, content: &str) -> String

Normalize plain text content

Source

pub fn hash_canonicalized( &self, content: &str, file_type: FileType, ) -> Result<String, Error>

Compute BLAKE3 hash of canonicalized content with FileType dispatch For YAML: uses JCS (RFC 8785) canonicalization of JSON representation For Markdown: uses v1 normalization rules For Text: uses basic line ending normalization

Source

pub fn hash_canonicalized_with_context( &self, content: &str, file_type: FileType, phase: &str, ) -> Result<String, XCheckerError>

Compute BLAKE3 hash of canonicalized content with error context

Trait Implementations§

Source§

impl Default for Canonicalizer

Source§

fn default() -> Canonicalizer

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more