Sync computers
This commit is contained in:
51
src/virtual_fs/null.rs
Normal file
51
src/virtual_fs/null.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use alloc::boxed::Box;
|
||||
use io::{IoBase, Read, Seek, Write};
|
||||
|
||||
use crate::virtual_fs::{VirtualFileSystem, VirtualNode};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Null;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct NullNode;
|
||||
|
||||
impl VirtualFileSystem for Null {
|
||||
fn open(
|
||||
&mut self,
|
||||
path: &bffs::path::Path,
|
||||
) -> Result<alloc::boxed::Box<dyn crate::virtual_fs::VirtualNode + '_>, ()> {
|
||||
if !path.is_empty() {
|
||||
Err(())
|
||||
} else {
|
||||
Ok(Box::new(NullNode))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IoBase for NullNode {
|
||||
type Error = ();
|
||||
}
|
||||
|
||||
impl Read for NullNode {
|
||||
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, Self::Error> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Seek for NullNode {
|
||||
fn seek(&mut self, _pos: io::SeekFrom) -> Result<u64, Self::Error> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Write for NullNode {
|
||||
fn write(&mut self, _buf: &[u8]) -> Result<usize, Self::Error> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> Result<(), Self::Error> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualNode for NullNode {}
|
||||
Reference in New Issue
Block a user