From 43e1a12b5bce11b4a28a53acca243e35c2be6d3e Mon Sep 17 00:00:00 2001 From: evuez Date: Wed, 3 Apr 2024 22:43:16 +0200 Subject: Initial commit --- src/client/fs/fcache.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/client/fs/fcache.rs (limited to 'src/client/fs/fcache.rs') diff --git a/src/client/fs/fcache.rs b/src/client/fs/fcache.rs new file mode 100644 index 0000000..03785c0 --- /dev/null +++ b/src/client/fs/fcache.rs @@ -0,0 +1,31 @@ +use super::{file::File, ino::Ino}; +use std::collections::HashMap; + +#[derive(Debug)] +pub struct Fcache { + inner: HashMap, +} + +impl Fcache { + pub fn new() -> Self { + Self { + inner: HashMap::new(), + } + } + + pub fn insert(&mut self, ino: Ino, file: File) -> Option { + self.inner.insert(ino, file) + } + + pub fn get(&self, ino: Ino) -> Option<&File> { + self.inner.get(&ino) + } + + pub fn get_mut(&mut self, ino: Ino) -> Option<&mut File> { + self.inner.get_mut(&ino) + } + + pub fn remove(&mut self, ino: Ino) -> Option { + self.inner.remove(&ino) + } +} -- cgit v1.2.3