Trait Utf8Encoding

Source
pub trait Utf8Encoding: Sealed {
    type Components<'a>: Utf8Components<'a>;

    // Required methods
    fn label() -> &'static str;
    fn components(path: &str) -> Self::Components<'_>;
    fn hash<H: Hasher>(path: &str, h: &mut H);
    fn push(current_path: &mut String, path: &str);
    fn push_checked(
        current_path: &mut String,
        path: &str,
    ) -> Result<(), CheckedPathError>;
}
Expand description

Interface to provide meaning to a byte slice such that paths can be derived

Required Associated Types§

Source

type Components<'a>: Utf8Components<'a>

Represents the type of component that will be derived by this encoding

Required Methods§

Source

fn label() -> &'static str

Static label representing encoding type

Source

fn components(path: &str) -> Self::Components<'_>

Produces an iterator of Utf8Components over the given the byte slice (path)

Source

fn hash<H: Hasher>(path: &str, h: &mut H)

Hashes a utf8 str (path)

Source

fn push(current_path: &mut String, path: &str)

Pushes a utf8 str (path) onto the an existing path (current_path)

Source

fn push_checked( current_path: &mut String, path: &str, ) -> Result<(), CheckedPathError>

Like Utf8Encoding::push, but enforces several new rules:

  1. path cannot contain a prefix component.
  2. path cannot contain a root component.
  3. path cannot contain invalid filename characters.
  4. path cannot contain parent components such that the current path would be escaped.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§