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>
👎Deprecated since 0.19.0: use Resources::walk(location) instead
pub fn collect_work( &self, location: impl AsRef<Path>, ) -> impl Iterator<Item = PathBuf>
use Resources::walk(location) instead
Collects all files in the specified location. Deprecated in favor of Self::walk.
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 get_bytes(
&self,
location: impl AsRef<Path>,
) -> Result<Vec<u8>, ResourceError>
pub fn get_bytes( &self, location: impl AsRef<Path>, ) -> Result<Vec<u8>, ResourceError>
Reads the contents of a file as bytes.
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.
Sourcepub fn write_bytes(
&self,
location: impl AsRef<Path>,
content: &[u8],
) -> Result<(), ResourceError>
pub fn write_bytes( &self, location: impl AsRef<Path>, content: &[u8], ) -> Result<(), ResourceError>
Writes content to a file as bytes.
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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 more