Skip to main content

File

Trait File 

Source
pub trait File:
    Display
    + Clone
    + Debug
    + 'static {
    type Char: Character;
    type SourceRefID: Copy + Debug + Default;
    type LineSource: FileLineSource<Self::Char>;

    // Required methods
    fn path(&self) -> &Path;
    fn line_source(self) -> Result<Self::LineSource, PathBuf>;
    fn size(&self) -> usize;
    fn sourceref(&self) -> Self::SourceRefID;

    // Provided method
    fn exists(&self) -> bool { ... }
}
Expand description

A (virtual or physical) file.

Required Associated Types§

Source

type Char: Character

The type of characters to be read from the file.

Source

type SourceRefID: Copy + Debug + Default

A Copyable identifier for this file to be used in SourceReferences.

Source

type LineSource: FileLineSource<Self::Char>

The type of line sources to be read from the file.

Required Methods§

Source

fn path(&self) -> &Path

Returns the path of this file.

Source

fn line_source(self) -> Result<Self::LineSource, PathBuf>

Returns a line source for this file. Used by a Mouth to read from this file.

Source

fn size(&self) -> usize

Returns the size of this file in bytes.

Source

fn sourceref(&self) -> Self::SourceRefID

Returns a SourceRefID for this file.

Provided Methods§

Source

fn exists(&self) -> bool

Returns whether this file exists.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§