Path

Trait Path 

Source
pub unsafe trait Path: Debug + Display {
    // Required method
    fn as_bytes(&self) -> &[u8] ;

    // Provided methods
    fn as_ptr(&self) -> *const u8 { ... }
    fn size(&self) -> usize { ... }
    fn len_steps(&self) -> usize { ... }
}
Expand description

Marker trait for methods on types representing path-encodings.

Path encoding maintains the following invariants:

  • paths begin with b'/'.
  • paths are a sequence of non-empty steps, separated by a single b'/'.
  • steps are a sequence of either ascii-encoded alphanumeric bytes, or b'.' or b'_' or b'-'.
  • the maximum length of a path is PATH_MAX_SIZE. where b'/' is the PATH_SEPARATOR.

i.e. path encoding may be summarised by the regex (\/[A-Za-z0-9._\-]+)+ up to a maximum PATH_MAX_SIZE bytes.

§Safety

Path is unsafe to implement, as other code (e.g. Runtime) rely on any T: impl Path being correctly path-encoded.

Required Methods§

Source

fn as_bytes(&self) -> &[u8]

Returns a read-only reference to the underlying path-encoded byte-slice.

Provided Methods§

Source

fn as_ptr(&self) -> *const u8

Returns a pointer to the beginning of the path.

Source

fn size(&self) -> usize

Returns the size of the path in bytes.

Source

fn len_steps(&self) -> usize

Returns the length of the path, as decomposed into a sequence of steps.

Implementors§