Crates.io | fs_pro |
lib.rs | fs_pro |
version | 1.3.0 |
source | src |
created_at | 2020-10-23 15:00:02.272386 |
updated_at | 2021-01-15 17:44:09.901604 |
description | a lib to work with files and folders easliy |
homepage | https://github.com/AliBasicCoder/fs-pro-rust |
repository | https://github.com/AliBasicCoder/fs-pro-rust.git |
max_upload_size | |
id | 304693 |
size | 73,837 |
A library to work with files easily
the is a beta rust version of fs-pro
see the full docs here
use fs_pro::{Dir, File, Shape, error::Result};
#[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() -> Result<()> {
let file = File::new("my_file.txt");
// create the file
file.create();
// write to file
file.write("hello there");
// read file
file.read_to_string(); // => "hello there"
// and much more...
let dir = Dir::new("my_dir");
// create the dir
dir.create();
// create a file in it
dir.create_file("my_file.txt").unwrap().write("hello world");
// create a dir in it
dir.create_dir("my_dir");
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
// and much more...
Ok(())
}
Copyright (c) 2020 AliBasicCoder