Trait FileSystem

Source
pub trait FileSystem: Sized {
    // Required methods
    fn new_source_id_with_line_starts(
        &mut self,
        path: PathBuf,
        content: String,
    ) -> (SourceId, LineStarts);
    fn get_source_by_id<T, F: for<'a> FnOnce(&'a Source) -> T>(
        &self,
        source_id: SourceId,
        f: F,
    ) -> T;

    // Provided methods
    fn new_source_id(&mut self, path: PathBuf, content: String) -> SourceId { ... }
    fn get_file_path_and_content(
        &self,
        source_id: SourceId,
    ) -> (PathBuf, String) { ... }
    fn get_file_path(&self, source_id: SourceId) -> PathBuf { ... }
    fn get_file_content(&self, source_id: SourceId) -> String { ... }
    fn get_file_whole_span(&self, source_id: SourceId) -> SpanWithSource { ... }
    fn get_file_slice<I: SliceIndex<str>>(
        &self,
        source_id: SourceId,
        indexer: I,
    ) -> Option<<I::Output as ToOwned>::Owned>
       where I::Output: Sized + ToOwned { ... }
}

Required Methods§

Source

fn new_source_id_with_line_starts( &mut self, path: PathBuf, content: String, ) -> (SourceId, LineStarts)

Source

fn get_source_by_id<T, F: for<'a> FnOnce(&'a Source) -> T>( &self, source_id: SourceId, f: F, ) -> T

Provided Methods§

Source

fn new_source_id(&mut self, path: PathBuf, content: String) -> SourceId

Generate a new SourceId

Source

fn get_file_path_and_content(&self, source_id: SourceId) -> (PathBuf, String)

Source

fn get_file_path(&self, source_id: SourceId) -> PathBuf

Source

fn get_file_content(&self, source_id: SourceId) -> String

Source

fn get_file_whole_span(&self, source_id: SourceId) -> SpanWithSource

Source

fn get_file_slice<I: SliceIndex<str>>( &self, source_id: SourceId, indexer: I, ) -> Option<<I::Output as ToOwned>::Owned>
where I::Output: Sized + ToOwned,

Note that this does clone the result

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§