Skip to main content

pseudo_directory

Macro pseudo_directory 

Source
macro_rules! pseudo_directory {
    ( $( $name:expr => $entry:expr ),* $(,)? ) => { ... };
}
Expand description

Builds a pseudo directory using a simple DSL. The directory entry names must be static strings (&'static str).

§Examples

This will construct a small tree of read-only files:

let root = pseudo_directory! {
    "etc" => pseudo_directory! {
        "fstab" => read_only(b"/dev/fs /"),
        "passwd" => read_only(b"[redacted]"),
        "shells" => read_only(b"/bin/bash"),
        "ssh" => pseudo_directory! {
          "sshd_config" => read_only(b"# Empty"),
        },
    },
    "uname" => read_only(b"Fuchsia"),
};

§Panics

This macro will panic if there are duplicate entries or any of the entry names are invalid. See name::validate_name for the restrictions.