wasi-common: break dep on system-interface by defining our own Advice enum
This commit is contained in:
@@ -13,12 +13,7 @@ pub trait WasiFile {
|
||||
fn set_fdflags(&mut self, flags: FdFlags) -> Result<(), Error>; // file op
|
||||
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>; // file op
|
||||
fn advise(&self, offset: u64, len: u64, advice: Advice) -> Result<(), Error>; // file op
|
||||
fn allocate(&self, offset: u64, len: u64) -> Result<(), Error>; // write op
|
||||
fn set_times(
|
||||
&self,
|
||||
@@ -170,3 +165,13 @@ pub struct FdStat {
|
||||
pub caps: FileCaps,
|
||||
pub flags: FdFlags,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Advice {
|
||||
Normal,
|
||||
Sequential,
|
||||
Random,
|
||||
WillNeed,
|
||||
DontNeed,
|
||||
NoReuse,
|
||||
}
|
||||
|
||||
@@ -10,14 +10,13 @@
|
||||
//! but the virtual pipes can be instantiated with any `Read` or `Write` type.
|
||||
//!
|
||||
use crate::{
|
||||
file::{FdFlags, FileType, Filestat, WasiFile},
|
||||
file::{Advice, FdFlags, FileType, Filestat, WasiFile},
|
||||
Error, ErrorExt, SystemTimeSpec,
|
||||
};
|
||||
use std::any::Any;
|
||||
use std::convert::TryInto;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use system_interface::fs::Advice;
|
||||
|
||||
/// A virtual pipe read end.
|
||||
///
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::{
|
||||
dir::{DirCaps, DirEntry, DirEntryExt, DirFdStat, ReaddirCursor, ReaddirEntity, TableDirExt},
|
||||
file::{
|
||||
FdFlags, FdStat, FileCaps, FileEntry, FileEntryExt, FileEntryMutExt, FileType, Filestat,
|
||||
OFlags, TableFileExt,
|
||||
Advice, FdFlags, FdStat, FileCaps, FileEntry, FileEntryExt, FileEntryMutExt, FileType,
|
||||
Filestat, OFlags, TableFileExt,
|
||||
},
|
||||
sched::{
|
||||
subscription::{RwEventFlags, SubscriptionResult},
|
||||
@@ -1081,15 +1081,15 @@ impl<'a> wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<types::Advice> for system_interface::fs::Advice {
|
||||
fn from(advice: types::Advice) -> system_interface::fs::Advice {
|
||||
impl From<types::Advice> for Advice {
|
||||
fn from(advice: types::Advice) -> Advice {
|
||||
match advice {
|
||||
types::Advice::Normal => system_interface::fs::Advice::Normal,
|
||||
types::Advice::Sequential => system_interface::fs::Advice::Sequential,
|
||||
types::Advice::Random => system_interface::fs::Advice::Random,
|
||||
types::Advice::Willneed => system_interface::fs::Advice::WillNeed,
|
||||
types::Advice::Dontneed => system_interface::fs::Advice::DontNeed,
|
||||
types::Advice::Noreuse => system_interface::fs::Advice::NoReuse,
|
||||
types::Advice::Normal => Advice::Normal,
|
||||
types::Advice::Sequential => Advice::Sequential,
|
||||
types::Advice::Random => Advice::Random,
|
||||
types::Advice::Willneed => Advice::WillNeed,
|
||||
types::Advice::Dontneed => Advice::DontNeed,
|
||||
types::Advice::Noreuse => Advice::NoReuse,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user