[−][src]Struct fs_pro::shape::Shape
Shape is a struct used to create directory with a specified Shape
in the example below we are defining shaped like so
the directory will contain
- a file named "my_file.txt" and it's identifier (the named that we will access it with in our code) will be "my_file"
- a directory called "my_dir"
- a directory that will contain
- a file named "child_file.txt" and it's identifier will be "child_file"
example:
use fs_pro::{File, Dir, Shape}; #[derive(Shape)] struct ChildShapedDir { #[name = "child_file.txt"] child_file: File /// ... } #[derive(Shape)] struct MyShapedDir { #[name = "my_file.txt"] my_file: File, #[pattern = "*.txt"] my_dir: Dir, child_shaped_dir: ChildShapedDir } fn main() { let shape: Shape<MyShapedDir> = Shape::new(); let shape_inst = shape.create_at("target").unwrap(); println!("{:?}", shape_inst.my_file); // File println!("{:?}", shape_inst.my_dir); // Dir println!("{:?}", shape_inst.child_shaped_dir.child_file); // File }
Implementations
impl<T: ShapeDescribe> Shape<T>
[src]
pub fn new() -> Self
[src]
creates a new shape
pub fn create_at<'a, P: 'a + AsRef<Path>>(&self, path: P) -> Result<T, Error>
[src]
create the shape in a directory
pub fn create_at_hook<'a, P: 'a + AsRef<Path>>(
&self,
path: P,
hook: &'a dyn Fn(PathBuf, bool)
) -> Result<T, Error>
[src]
&self,
path: P,
hook: &'a dyn Fn(PathBuf, bool)
) -> Result<T, Error>
pub fn validate<'a, P: 'a + AsRef<Path>>(
&self,
path: P
) -> Result<(), Vec<Error>>
[src]
&self,
path: P
) -> Result<(), Vec<Error>>
checks if a folder matches the shape and returns list of errors if they don't match the errors specify why and where they are not matching
Meaning of Errors
- NotFound if any file or folder doesn't exist
- Interrupted if operation interrupts (aka been stooped)
- InvalidFile if a file that doesn't match the pattern in a pattern dir was found
- InvalidFolder if a folder was found in a pattern dir
- PermissionDenied if the os refuses to give the program permission to read form disk any other error that's not listed is IMPOSSIBLE to occur
Trait Implementations
impl<T: ShapeDescribe> Debug for Shape<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Shape<T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Send for Shape<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for Shape<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for Shape<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Shape<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,