Skip to content

Commit c645077

Browse files
authored
Add public accessors of sub-contexts of WasiCtx (#11473)
This is intended to assist with embedders who aren't necessarily using `WasiView` for everything.
1 parent 1d371af commit c645077

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

crates/wasi/src/ctx.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,4 +528,29 @@ impl WasiCtx {
528528
pub fn builder() -> WasiCtxBuilder {
529529
WasiCtxBuilder::new()
530530
}
531+
532+
/// Returns access to the underlying [`WasiRandomCtx`].
533+
pub fn random(&mut self) -> &mut WasiRandomCtx {
534+
&mut self.random
535+
}
536+
537+
/// Returns access to the underlying [`WasiClocksCtx`].
538+
pub fn clocks(&mut self) -> &mut WasiClocksCtx {
539+
&mut self.clocks
540+
}
541+
542+
/// Returns access to the underlying [`WasiFilesystemCtx`].
543+
pub fn filesystem(&mut self) -> &mut WasiFilesystemCtx {
544+
&mut self.filesystem
545+
}
546+
547+
/// Returns access to the underlying [`WasiCliCtx`].
548+
pub fn cli(&mut self) -> &mut WasiCliCtx {
549+
&mut self.cli
550+
}
551+
552+
/// Returns access to the underlying [`WasiSocketsCtx`].
553+
pub fn sockets(&mut self) -> &mut WasiSocketsCtx {
554+
&mut self.sockets
555+
}
531556
}

0 commit comments

Comments
 (0)