[][src]Trait smolapps::tftp::Context

pub trait Context {
    type Handle: Handle;
    fn open(
        &mut self,
        filename: &str,
        write_mode: bool
    ) -> Result<Self::Handle, ()>;
fn close(&mut self, handle: Self::Handle); }

The context over which the Server will operate.

The context allows the Server to open and close Handles to files. It does not impose any restriction on the context hierarchy: it could be a flat structure or implement a directory tree. It is up to the implementors to define, if required, the concepts of path separators and nesting levels.

Associated Types

type Handle: Handle

The Handle type used by this Context.

Loading content...

Required methods

fn open(&mut self, filename: &str, write_mode: bool) -> Result<Self::Handle, ()>

Attempts to open a file in read-only mode if write_mode is false, otherwise in read-write mode.

The filename contained in the request packet is provided as-is: no modifications are applied besides stripping the NULL terminator.

fn close(&mut self, handle: Self::Handle)

Closes the file handle, flushing all pending changes to disk if necessary.

Loading content...

Implementors

Loading content...