//! Preserves read-only mount errors for mutations through open descriptors. use crate::*; pub(crate) struct Readonly(pub Arc); fn denied() -> Result { Err(error(io::ErrorKind::ReadOnlyFilesystem)) } #[async_trait] impl File for Readonly { async fn stat(&self) -> Result { self.0.stat().await } async fn read(&self, offset: u64, length: usize) -> Result> { self.0.read(offset, length).await } async fn write(&self, _: u64, _: Vec) -> Result { denied() } async fn append(&self, _: Vec) -> Result { denied() } async fn set_size(&self, _: u64) -> Result<()> { denied() } async fn sync(&self) -> Result<()> { self.0.sync().await } async fn set_times(&self, _: Option, _: Option) -> Result<()> { denied() } }