fix tests and exports
This commit is contained in:
@@ -10,9 +10,12 @@ pub mod snapshots;
|
|||||||
mod string_array;
|
mod string_array;
|
||||||
pub mod table;
|
pub mod table;
|
||||||
|
|
||||||
pub use clocks::SystemTimeSpec;
|
pub use cap_rand::RngCore;
|
||||||
|
pub use clocks::{SystemTimeSpec, WasiClocks, WasiMonotonicClock, WasiSystemClock};
|
||||||
pub use ctx::{WasiCtx, WasiCtxBuilder};
|
pub use ctx::{WasiCtx, WasiCtxBuilder};
|
||||||
pub use dir::{DirCaps, ReaddirCursor, ReaddirEntity, WasiDir};
|
pub use dir::WasiDir;
|
||||||
pub use error::{Error, ErrorExt, ErrorKind};
|
pub use error::{Error, ErrorExt, ErrorKind};
|
||||||
pub use file::{FdFlags, FileCaps, Filestat, OFlags, WasiFile};
|
pub use file::WasiFile;
|
||||||
|
pub use sched::{Poll, WasiSched};
|
||||||
pub use string_array::StringArrayError;
|
pub use string_array::StringArrayError;
|
||||||
|
pub use table::Table;
|
||||||
|
|||||||
@@ -22,11 +22,19 @@ use std::sync::{Arc, RwLock};
|
|||||||
///
|
///
|
||||||
/// A variety of `From` impls are provided so that common pipe types are easy to create. For example:
|
/// A variety of `From` impls are provided so that common pipe types are easy to create. For example:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```no_run
|
||||||
/// # use wasi_c2::WasiCtx;
|
/// # use std::rc::Rc;
|
||||||
/// # use wasi_c2::virt::pipe::ReadPipe;
|
/// # use std::cell::RefCell;
|
||||||
|
/// use wasi_common::{pipe::ReadPipe, WasiCtx, Table};
|
||||||
/// let stdin = ReadPipe::from("hello from stdin!");
|
/// let stdin = ReadPipe::from("hello from stdin!");
|
||||||
/// let ctx = WasiCtx::builder().stdin(Box::new(stdin)).build();
|
/// // Brint these instances from elsewhere (e.g. wasi-cap-std-sync):
|
||||||
|
/// let random = todo!();
|
||||||
|
/// let clocks = todo!();
|
||||||
|
/// let sched = todo!();
|
||||||
|
/// let table = Rc::new(RefCell::new(Table::new()));
|
||||||
|
/// let ctx = WasiCtx::builder(random, clocks, sched, table)
|
||||||
|
/// .stdin(Box::new(stdin.clone()))
|
||||||
|
/// .build();
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ReadPipe<R: Read> {
|
pub struct ReadPipe<R: Read> {
|
||||||
@@ -170,11 +178,19 @@ impl<R: Read + Any> WasiFile for ReadPipe<R> {
|
|||||||
|
|
||||||
/// A virtual pipe write end.
|
/// A virtual pipe write end.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```no_run
|
||||||
/// # use wasi_c2::WasiCtx;
|
/// # use std::rc::Rc;
|
||||||
/// # use wasi_c2::virt::pipe::WritePipe;
|
/// # use std::cell::RefCell;
|
||||||
|
/// use wasi_common::{pipe::WritePipe, WasiCtx, Table};
|
||||||
/// let stdout = WritePipe::new_in_memory();
|
/// let stdout = WritePipe::new_in_memory();
|
||||||
/// let ctx = WasiCtx::builder().stdout(Box::new(stdout.clone())).build();
|
/// // Brint these instances from elsewhere (e.g. wasi-cap-std-sync):
|
||||||
|
/// let random = todo!();
|
||||||
|
/// let clocks = todo!();
|
||||||
|
/// let sched = todo!();
|
||||||
|
/// let table = Rc::new(RefCell::new(Table::new()));
|
||||||
|
/// let ctx = WasiCtx::builder(random, clocks, sched, table)
|
||||||
|
/// .stdout(Box::new(stdout.clone()))
|
||||||
|
/// .build();
|
||||||
/// // use ctx in an instance, then make sure it is dropped:
|
/// // use ctx in an instance, then make sure it is dropped:
|
||||||
/// drop(ctx);
|
/// drop(ctx);
|
||||||
/// let contents: Vec<u8> = stdout.try_into_inner().expect("sole remaining reference to WritePipe").into_inner();
|
/// let contents: Vec<u8> = stdout.try_into_inner().expect("sole remaining reference to WritePipe").into_inner();
|
||||||
|
|||||||
Reference in New Issue
Block a user