pub struct SafeSys { /* private fields */ }Expand description
A safe backend with no IO other than captured stdout and stderr
Implementations§
Trait Implementations§
source§impl SysBackend for SafeSys
impl SysBackend for SafeSys
source§fn print_str_stdout(&self, s: &str) -> Result<(), String>
fn print_str_stdout(&self, s: &str) -> Result<(), String>
Print a string (without a newline) to stdout
source§fn print_str_stderr(&self, s: &str) -> Result<(), String>
fn print_str_stderr(&self, s: &str) -> Result<(), String>
Print a string (without a newline) to stderr
source§fn save_error_color(&self, message: String, colored: String)
fn save_error_color(&self, message: String, colored: String)
Save a color-formatted version of an error message for later printing
source§fn print_str_trace(&self, s: &str)
fn print_str_trace(&self, s: &str)
Print a string that was create by
tracesource§fn file_exists(&self, path: &str) -> bool
fn file_exists(&self, path: &str) -> bool
Check if a file exists
source§fn list_dir(&self, path: &str) -> Result<Vec<String>, String>
fn list_dir(&self, path: &str) -> Result<Vec<String>, String>
List the contents of a directory
source§fn read(&self, handle: Handle, count: usize) -> Result<Vec<u8>, String>
fn read(&self, handle: Handle, count: usize) -> Result<Vec<u8>, String>
Read at most
count bytes from a streamsource§fn read_all(&self, handle: Handle) -> Result<Vec<u8>, String>
fn read_all(&self, handle: Handle) -> Result<Vec<u8>, String>
Read from a stream until the end
source§fn read_until(&self, handle: Handle, delim: &[u8]) -> Result<Vec<u8>, String>
fn read_until(&self, handle: Handle, delim: &[u8]) -> Result<Vec<u8>, String>
Read from a stream until a delimiter is reached
source§fn write(&self, handle: Handle, contents: &[u8]) -> Result<(), String>
fn write(&self, handle: Handle, contents: &[u8]) -> Result<(), String>
Write bytes to a stream
source§fn file_write_all(&self, path: &Path, contents: &[u8]) -> Result<(), String>
fn file_write_all(&self, path: &Path, contents: &[u8]) -> Result<(), String>
Write all bytes to a file
source§fn sleep(&self, seconds: f64) -> Result<(), String>
fn sleep(&self, seconds: f64) -> Result<(), String>
Sleep the current thread for
seconds secondssource§fn show_image(&self, image: DynamicImage) -> Result<(), String>
fn show_image(&self, image: DynamicImage) -> Result<(), String>
Show an image
source§fn audio_sample_rate(&self) -> u32
fn audio_sample_rate(&self) -> u32
Get the audio sample rate
source§fn stream_audio(&self, f: AudioStreamFn) -> Result<(), String>
fn stream_audio(&self, f: AudioStreamFn) -> Result<(), String>
Stream audio
source§fn tcp_listen(&self, addr: &str) -> Result<Handle, String>
fn tcp_listen(&self, addr: &str) -> Result<Handle, String>
Create a TCP listener and bind it to an address
source§fn tcp_accept(&self, handle: Handle) -> Result<Handle, String>
fn tcp_accept(&self, handle: Handle) -> Result<Handle, String>
Accept a connection with a TCP listener
source§fn tcp_connect(&self, addr: &str) -> Result<Handle, String>
fn tcp_connect(&self, addr: &str) -> Result<Handle, String>
Create a TCP socket and connect it to an address
source§fn tcp_addr(&self, handle: Handle) -> Result<String, String>
fn tcp_addr(&self, handle: Handle) -> Result<String, String>
Get the connection address of a TCP socket
source§fn tcp_set_non_blocking(
&self,
handle: Handle,
non_blocking: bool
) -> Result<(), String>
fn tcp_set_non_blocking( &self, handle: Handle, non_blocking: bool ) -> Result<(), String>
Set a TCP socket to non-blocking mode
source§fn tcp_set_read_timeout(
&self,
handle: Handle,
timeout: Option<Duration>
) -> Result<(), String>
fn tcp_set_read_timeout( &self, handle: Handle, timeout: Option<Duration> ) -> Result<(), String>
Set the read timeout of a TCP socket
source§fn tcp_set_write_timeout(
&self,
handle: Handle,
timeout: Option<Duration>
) -> Result<(), String>
fn tcp_set_write_timeout( &self, handle: Handle, timeout: Option<Duration> ) -> Result<(), String>
Set the write timeout of a TCP socket
source§fn invoke(&self, path: &str) -> Result<(), String>
fn invoke(&self, path: &str) -> Result<(), String>
Invoke a path with the system’s default program
source§fn run_command_inherit(
&self,
command: &str,
args: &[&str]
) -> Result<i32, String>
fn run_command_inherit( &self, command: &str, args: &[&str] ) -> Result<i32, String>
Run a command, inheriting standard IO
source§fn run_command_capture(
&self,
command: &str,
args: &[&str]
) -> Result<(i32, String, String), String>
fn run_command_capture( &self, command: &str, args: &[&str] ) -> Result<(i32, String, String), String>
Run a command, capturing standard IO
source§fn run_command_stream(
&self,
command: &str,
args: &[&str]
) -> Result<Handle, String>
fn run_command_stream( &self, command: &str, args: &[&str] ) -> Result<Handle, String>
Run a command and return an IO stream handle
source§fn https_get(&self, request: &str, handle: Handle) -> Result<String, String>
fn https_get(&self, request: &str, handle: Handle) -> Result<String, String>
Make an HTTPS request on a TCP socket
Auto Trait Implementations§
impl !RefUnwindSafe for SafeSys
impl Send for SafeSys
impl Sync for SafeSys
impl Unpin for SafeSys
impl !UnwindSafe for SafeSys
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoSysBackend for T
impl<T> IntoSysBackend for T
source§fn into_sys_backend(self) -> Arc<dyn SysBackend>
fn into_sys_backend(self) -> Arc<dyn SysBackend>
Convert to a reference counted system backend
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().