use crate::error::CNFSResult;
use crate::CNFSError::NotImplemented;
use alloc::sync::Arc;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum InodeType {
Dir,
File,
}
pub trait Inode: Send + Sync {
fn read(&self, _offset: u64, _buffer: &mut [u8]) -> CNFSResult<usize>
{
Err(NotImplemented)
}
fn write(&self, _offset: u64, _buffer: &[u8]) -> CNFSResult<usize>
{
Err(NotImplemented)
}
fn sync(&self) -> CNFSResult
{
Err(NotImplemented)
}
fn lookup(&self, _name: &str) -> CNFSResult<InodeRef>
{
Err(NotImplemented)
}
fn create(&self, _name: &str, _inode_type: InodeType) -> CNFSResult<InodeRef>
{
Err(NotImplemented)
}
fn remove(&self, _name: &str) -> CNFSResult
{
Err(NotImplemented)
}
}
pub type InodeRef = Arc<dyn Inode>;
pub trait FileSystem: Send + Sync {
fn root_inode(&self) -> InodeRef;
}