pub trait Encoding: Sealed {
type Components<'a>: Components<'a>;
// Required methods
fn label() -> &'static str;
fn components(path: &[u8]) -> Self::Components<'_>;
fn hash<H: Hasher>(path: &[u8], h: &mut H);
fn push(current_path: &mut Vec<u8>, path: &[u8]);
fn push_checked(
current_path: &mut Vec<u8>,
path: &[u8],
) -> Result<(), CheckedPathError>;
}
Expand description
Interface to provide meaning to a byte slice such that paths can be derived
Required Associated Types§
Sourcetype Components<'a>: Components<'a>
type Components<'a>: Components<'a>
Represents the type of component that will be derived by this encoding
Required Methods§
Sourcefn components(path: &[u8]) -> Self::Components<'_>
fn components(path: &[u8]) -> Self::Components<'_>
Produces an iterator of Component
s over the given the byte slice (path
)
Sourcefn push(current_path: &mut Vec<u8>, path: &[u8])
fn push(current_path: &mut Vec<u8>, path: &[u8])
Pushes a byte slice (path
) onto the an existing path (current_path
)
Sourcefn push_checked(
current_path: &mut Vec<u8>,
path: &[u8],
) -> Result<(), CheckedPathError>
fn push_checked( current_path: &mut Vec<u8>, path: &[u8], ) -> Result<(), CheckedPathError>
Like Encoding::push
, but enforces several new rules:
path
cannot contain a prefix component.path
cannot contain a root component.path
cannot contain invalid filename bytes.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.