pub struct Resources { /* private fields */ }
Expand description
A resource manager for handling file operations.
This struct provides an abstraction over file system operations, allowing operations to be performed either on the actual file system or in memory. It handles reading, writing, and managing files and directories.
Implementations§
Source§impl Resources
impl Resources
Sourcepub fn from_file_system() -> Self
pub fn from_file_system() -> Self
Creates a new resource manager that operates on the file system.
Sourcepub fn from_memory() -> Self
pub fn from_memory() -> Self
Creates a new resource manager that operates in memory.
This is useful for testing or when you want to process files without writing to disk.
Sourcepub fn collect_work(
&self,
location: impl AsRef<Path>,
) -> impl Iterator<Item = PathBuf>
pub fn collect_work( &self, location: impl AsRef<Path>, ) -> impl Iterator<Item = PathBuf>
Collects all Lua and Luau files in the specified location.
Sourcepub fn exists(&self, location: impl AsRef<Path>) -> Result<bool, ResourceError>
pub fn exists(&self, location: impl AsRef<Path>) -> Result<bool, ResourceError>
Checks if a path exists.
Sourcepub fn is_directory(
&self,
location: impl AsRef<Path>,
) -> Result<bool, ResourceError>
pub fn is_directory( &self, location: impl AsRef<Path>, ) -> Result<bool, ResourceError>
Checks if a path is a directory.
Sourcepub fn is_file(&self, location: impl AsRef<Path>) -> Result<bool, ResourceError>
pub fn is_file(&self, location: impl AsRef<Path>) -> Result<bool, ResourceError>
Checks if a path is a file.
Sourcepub fn get(&self, location: impl AsRef<Path>) -> Result<String, ResourceError>
pub fn get(&self, location: impl AsRef<Path>) -> Result<String, ResourceError>
Reads the contents of a file.
Sourcepub fn write(
&self,
location: impl AsRef<Path>,
content: &str,
) -> Result<(), ResourceError>
pub fn write( &self, location: impl AsRef<Path>, content: &str, ) -> Result<(), ResourceError>
Writes content to a file.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resources
impl RefUnwindSafe for Resources
impl Send for Resources
impl Sync for Resources
impl Unpin for Resources
impl UnwindSafe for Resources
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
Source§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original
input to the nom parser, extract more the useful context information. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
Source§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom,
recreate a context in the original string where the error occurred. Read more