Skip to main content

FileSystem

Trait FileSystem 

Source
pub trait FileSystem: Clone {
    type File: File;

    // Required methods
    fn new(pwd: PathBuf) -> Self;
    fn get<S: AsRef<str>>(&mut self, path: S) -> Self::File;
    fn set_pwd(&mut self, pwd: PathBuf) -> PathBuf;
    fn open_out(&mut self, idx: u8, file: Self::File);
    fn open_in(&mut self, idx: u8, file: Self::File);
    fn close_in(&mut self, idx: u8);
    fn close_out(&mut self, idx: u8);
    fn eof(&self, idx: u8) -> bool;
    fn write<ET: EngineTypes, D: Display>(
        &mut self,
        idx: i64,
        string: D,
        newlinechar: Option<ET::Char>,
        aux: &mut EngineAux<ET>,
    );
    fn read<ET: EngineTypes<Char = <Self::File as File>::Char>, F: FnMut(ET::Token)>(
        &mut self,
        idx: u8,
        handler: &mut <ET::CSName as CSName<ET::Char>>::Handler,
        state: &ET::State,
        cont: F,
    ) -> TeXResult<(), ET>;
    fn readline<ET: EngineTypes<Char = <Self::File as File>::Char>, F: FnMut(ET::Token)>(
        &mut self,
        idx: u8,
        state: &ET::State,
        cont: F,
    ) -> TeXResult<(), ET>;
    fn ref_str(&self, id: <Self::File as File>::SourceRefID) -> &str;
}
Expand description

A FileSystem provides access to files.

Required Associated Types§

Source

type File: File

The type of files provided by this FileSystem.

Required Methods§

Source

fn new(pwd: PathBuf) -> Self

Creates a new FileSystem with the given working directory.

Source

fn get<S: AsRef<str>>(&mut self, path: S) -> Self::File

Returns the file with the given name in the file database. May return nonexistent files in the CWD

Source

fn set_pwd(&mut self, pwd: PathBuf) -> PathBuf

Sets the working directory of this FileSystem, returning the old working directory and updating the file database.

Source

fn open_out(&mut self, idx: u8, file: Self::File)

Opens the file with the given index for writing (\openout).

Source

fn open_in(&mut self, idx: u8, file: Self::File)

Opens the file with the given index for reading (\openin).

Source

fn close_in(&mut self, idx: u8)

Closes the file with the given index (\closein).

Source

fn close_out(&mut self, idx: u8)

Closes the file with the given index (\closeout).

Source

fn eof(&self, idx: u8) -> bool

Ehether the file with the given index is at its end (\ifeof).

Source

fn write<ET: EngineTypes, D: Display>( &mut self, idx: i64, string: D, newlinechar: Option<ET::Char>, aux: &mut EngineAux<ET>, )

Writes the given string to the file with the given index (\write).

Source

fn read<ET: EngineTypes<Char = <Self::File as File>::Char>, F: FnMut(ET::Token)>( &mut self, idx: u8, handler: &mut <ET::CSName as CSName<ET::Char>>::Handler, state: &ET::State, cont: F, ) -> TeXResult<(), ET>

Reads a line from the file with the given index and current CategoryCodeScheme (\read), respecting groups (i.e. will continue reading at the end of a line until all open groups are closed).

Source

fn readline<ET: EngineTypes<Char = <Self::File as File>::Char>, F: FnMut(ET::Token)>( &mut self, idx: u8, state: &ET::State, cont: F, ) -> TeXResult<(), ET>

Reads a line from the file with the given index using CategoryCode::Other expect for space characters (\readline).

Source

fn ref_str(&self, id: <Self::File as File>::SourceRefID) -> &str

Returns a human-readable representation of a SourceRefID; e.g. the file name/path.

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§