move more deps to cap-std-sync, define own SystemTimeSpec
This commit is contained in:
@@ -1,42 +1,43 @@
|
||||
use crate::Error;
|
||||
use crate::{Error, SystemTimeSpec};
|
||||
use bitflags::bitflags;
|
||||
use fs_set_times::SystemTimeSpec;
|
||||
use std::any::Any;
|
||||
use std::cell::Ref;
|
||||
use std::ops::Deref;
|
||||
|
||||
pub trait WasiFile {
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
fn datasync(&self) -> Result<(), Error>;
|
||||
fn sync(&self) -> Result<(), Error>;
|
||||
fn get_filetype(&self) -> Result<FileType, Error>;
|
||||
fn get_fdflags(&self) -> Result<FdFlags, Error>;
|
||||
fn datasync(&self) -> Result<(), Error>; // write op
|
||||
fn sync(&self) -> Result<(), Error>; // file op
|
||||
fn get_filetype(&self) -> Result<FileType, Error>; // file op
|
||||
fn get_fdflags(&self) -> Result<FdFlags, Error>; // file op
|
||||
fn set_fdflags(&self, _flags: FdFlags) -> Result<(), Error>;
|
||||
fn get_filestat(&self) -> Result<Filestat, Error>;
|
||||
fn set_filestat_size(&self, _size: u64) -> Result<(), Error>;
|
||||
fn get_filestat(&self) -> Result<Filestat, Error>; // split out get_length as a read & write op, rest is a file op
|
||||
fn set_filestat_size(&self, _size: u64) -> Result<(), Error>; // write op
|
||||
fn advise(
|
||||
&self,
|
||||
offset: u64,
|
||||
len: u64,
|
||||
advice: system_interface::fs::Advice,
|
||||
) -> Result<(), Error>;
|
||||
fn allocate(&self, offset: u64, len: u64) -> Result<(), Error>;
|
||||
) -> Result<(), Error>; // file op
|
||||
fn allocate(&self, offset: u64, len: u64) -> Result<(), Error>; // write op
|
||||
fn set_times(
|
||||
&self,
|
||||
atime: Option<SystemTimeSpec>,
|
||||
mtime: Option<SystemTimeSpec>,
|
||||
) -> Result<(), Error>;
|
||||
fn read_vectored(&self, bufs: &mut [std::io::IoSliceMut]) -> Result<u64, Error>;
|
||||
fn read_vectored(&self, bufs: &mut [std::io::IoSliceMut]) -> Result<u64, Error>; // read op
|
||||
fn read_vectored_at(&self, bufs: &mut [std::io::IoSliceMut], offset: u64)
|
||||
-> Result<u64, Error>;
|
||||
fn write_vectored(&self, bufs: &[std::io::IoSlice]) -> Result<u64, Error>;
|
||||
fn write_vectored_at(&self, bufs: &[std::io::IoSlice], offset: u64) -> Result<u64, Error>;
|
||||
fn seek(&self, pos: std::io::SeekFrom) -> Result<u64, Error>;
|
||||
fn stream_position(&self) -> Result<u64, Error>;
|
||||
fn peek(&self, buf: &mut [u8]) -> Result<u64, Error>;
|
||||
fn num_ready_bytes(&self) -> Result<u64, Error>;
|
||||
-> Result<u64, Error>; // file op
|
||||
fn write_vectored(&self, bufs: &[std::io::IoSlice]) -> Result<u64, Error>; // write op
|
||||
fn write_vectored_at(&self, bufs: &[std::io::IoSlice], offset: u64) -> Result<u64, Error>; // file op
|
||||
fn seek(&self, pos: std::io::SeekFrom) -> Result<u64, Error>; // file op that generates a new stream from a file will supercede this
|
||||
fn peek(&self, buf: &mut [u8]) -> Result<u64, Error>; // read op
|
||||
fn num_ready_bytes(&self) -> Result<u64, Error>; // read op
|
||||
}
|
||||
|
||||
// XXX we will add pipes to wasi - lets add it to this internal enum and present them as
|
||||
// Unknown to old wasis
|
||||
// XXX put the enum variants in same order as WASI so conversion funcs are no-op
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum FileType {
|
||||
Directory,
|
||||
@@ -74,7 +75,7 @@ pub struct Filestat {
|
||||
pub inode: u64,
|
||||
pub filetype: FileType,
|
||||
pub nlink: u64,
|
||||
pub size: u64,
|
||||
pub size: u64, // this is a read field, the rest are file fields
|
||||
pub atim: Option<std::time::SystemTime>,
|
||||
pub mtim: Option<std::time::SystemTime>,
|
||||
pub ctim: Option<std::time::SystemTime>,
|
||||
|
||||
Reference in New Issue
Block a user