need Any on WasiFile to upcast for AsRawFd

This commit is contained in:
Pat Hickey
2021-01-14 13:39:01 -08:00
parent ea94d6f79d
commit 5c8efe868e
7 changed files with 87 additions and 19 deletions

View File

@@ -1,11 +1,13 @@
use crate::Error;
use bitflags::bitflags;
use fs_set_times::SetTimes;
use std::any::Any;
use std::cell::Ref;
use std::ops::Deref;
use system_interface::fs::FileIoExt;
pub trait WasiFile: FileIoExt + SetTimes {
fn as_any(&self) -> &dyn Any;
fn datasync(&self) -> Result<(), Error>;
fn sync(&self) -> Result<(), Error>;
fn get_filetype(&self) -> Result<FileType, Error>;
@@ -165,6 +167,9 @@ pub struct FdStat {
}
impl WasiFile for cap_std::fs::File {
fn as_any(&self) -> &dyn Any {
self
}
fn datasync(&self) -> Result<(), Error> {
self.sync_data()?;
Ok(())