pub trait Host {
// Required methods
fn read_classified(
&self,
label: &str,
max: usize,
) -> Result<Option<Vec<u8>>, ReadFail>;
fn ensure_absent(&self, label: &str) -> Result<(), IoFail>;
fn create(&self, label: &str, bytes: &[u8]) -> Result<(), IoFail>;
fn write_all(&self, files: &[(String, Vec<u8>)]) -> Result<(), IoFail>;
fn join(&self, dir: &str, name: &str) -> String;
// Provided methods
fn read(&self, label: &str, limit: usize) -> Result<Vec<u8>, IoFail> { ... }
fn read_bounded(
&self,
label: &str,
max: usize,
) -> Result<Option<Vec<u8>>, IoFail> { ... }
}Expand description
The host of one command.
Required Methods§
Sourcefn read_classified(
&self,
label: &str,
max: usize,
) -> Result<Option<Vec<u8>>, ReadFail>
fn read_classified( &self, label: &str, max: usize, ) -> Result<Option<Vec<u8>>, ReadFail>
Read label, at most max bytes of it; None when it does not
exist. A failure of the input is told from an exhausted command
budget, which depends on read order rather than on the input.
Sourcefn ensure_absent(&self, label: &str) -> Result<(), IoFail>
fn ensure_absent(&self, label: &str) -> Result<(), IoFail>
Refuse an output that already exists, before any work. A pure check that changes nothing, so calling it again for the same label gives the same answer: commands check every output up front and again just before writing.
Sourcefn create(&self, label: &str, bytes: &[u8]) -> Result<(), IoFail>
fn create(&self, label: &str, bytes: &[u8]) -> Result<(), IoFail>
Publish one output, never overwriting.
Provided Methods§
Sourcefn read(&self, label: &str, limit: usize) -> Result<Vec<u8>, IoFail>
fn read(&self, label: &str, limit: usize) -> Result<Vec<u8>, IoFail>
Read label up to its document limit plus one byte, so an oversized
input reaches the parser and is refused by the document’s own bound.
Sourcefn read_bounded(
&self,
label: &str,
max: usize,
) -> Result<Option<Vec<u8>>, IoFail>
fn read_bounded( &self, label: &str, max: usize, ) -> Result<Option<Vec<u8>>, IoFail>
Like Host::read with an explicit maximum, returning None for an
input that does not exist.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".