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§
Sourcetype File: File
type File: File
The type of files provided by this FileSystem.
Required Methods§
Sourcefn new(pwd: PathBuf) -> Self
fn new(pwd: PathBuf) -> Self
Creates a new FileSystem with the given working directory.
Sourcefn get<S: AsRef<str>>(&mut self, path: S) -> Self::File
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
Sourcefn set_pwd(&mut self, pwd: PathBuf) -> PathBuf
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.
Sourcefn open_out(&mut self, idx: u8, file: Self::File)
fn open_out(&mut self, idx: u8, file: Self::File)
Opens the file with the given index for writing (\openout).
Sourcefn open_in(&mut self, idx: u8, file: Self::File)
fn open_in(&mut self, idx: u8, file: Self::File)
Opens the file with the given index for reading (\openin).
Sourcefn write<ET: EngineTypes, D: Display>(
&mut self,
idx: i64,
string: D,
newlinechar: Option<ET::Char>,
aux: &mut EngineAux<ET>,
)
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).
Sourcefn 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 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).
Sourcefn 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 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).
Sourcefn ref_str(&self, id: <Self::File as File>::SourceRefID) -> &str
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.