pub struct Entry {
pub bytes: Vec<u8>,
/* private fields */
}
Fields§
§bytes: Vec<u8>
Implementations§
Source§impl Entry
impl Entry
Sourcepub fn map(&self) -> Result<String>
pub fn map(&self) -> Result<String>
Map entry to physical location in your filesystem
Method returns path to the mapped file, or filesystem writing error
use kinda_virtual_fs::*;
let entry = Entry::new("Hello, World!");
let file_path = entry.map().expect("Failed to map entry");
let file_content = std::fs::read_to_string(file_path).expect("Failed to read mapped entry");
assert_eq!(&file_content, "Hello, World!");
Sourcepub fn unmap(&self) -> Result<()>
pub fn unmap(&self) -> Result<()>
Unmap (delete) entry from your filesystem
Entry will be automatically unmapped when its value is no more needed
§Manual unmapping
use kinda_virtual_fs::*;
let entry = Entry::new("Hello, World!");
let path = entry.map().unwrap();
assert_eq!(std::path::Path::new(&path).exists(), true);
entry.unmap();
assert_eq!(std::path::Path::new(&path).exists(), false);
§Automatic unmapping
use kinda_virtual_fs::*;
let path = {
let entry = Entry::new("Hello, World!");
let path = entry.map().unwrap();
assert_eq!(std::path::Path::new(&path).exists(), true);
path
};
// entry is dropped here because it's no more used
assert_eq!(std::path::Path::new(&path).exists(), false);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Entry
impl RefUnwindSafe for Entry
impl Send for Entry
impl Sync for Entry
impl Unpin for Entry
impl UnwindSafe for Entry
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