tendril::fmt

Trait Format

Source
pub unsafe trait Format {
    // Required method
    fn validate(buf: &[u8]) -> bool;

    // Provided methods
    fn validate_prefix(buf: &[u8]) -> bool { ... }
    fn validate_suffix(buf: &[u8]) -> bool { ... }
    fn validate_subseq(buf: &[u8]) -> bool { ... }
    unsafe fn fixup(_lhs: &[u8], _rhs: &[u8]) -> Fixup { ... }
}
Expand description

Trait for format marker types.

The type implementing this trait is usually not instantiated. It’s used with a phantom type parameter of Tendril.

Required Methods§

Source

fn validate(buf: &[u8]) -> bool

Check whether the buffer is valid for this format.

Provided Methods§

Source

fn validate_prefix(buf: &[u8]) -> bool

Check whether the buffer is valid for this format.

You may assume the buffer is a prefix of a valid buffer.

Source

fn validate_suffix(buf: &[u8]) -> bool

Check whether the buffer is valid for this format.

You may assume the buffer is a suffix of a valid buffer.

Source

fn validate_subseq(buf: &[u8]) -> bool

Check whether the buffer is valid for this format.

You may assume the buffer is a contiguous subsequence of a valid buffer, but not necessarily a prefix or a suffix.

Source

unsafe fn fixup(_lhs: &[u8], _rhs: &[u8]) -> Fixup

Compute any fixup needed when concatenating buffers.

The default is to do nothing.

The function is unsafe because it may assume the input buffers are already valid for the format. Also, no bounds-checking is performed on the return value!

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§