Struct uiua::SafeSys

source ·
pub struct SafeSys { /* private fields */ }
Expand description

A safe backend with no IO other than captured stdout and stderr

Implementations§

source§

impl SafeSys

source

pub fn new() -> Self

Create a new safe system backend

source

pub fn take_stdout(&self) -> Vec<u8>

Take the captured stdout

source

pub fn take_stderr(&self) -> Vec<u8>

Take the captured stderr

Trait Implementations§

source§

impl Default for SafeSys

source§

fn default() -> SafeSys

Returns the “default value” for a type. Read more
source§

impl SysBackend for SafeSys

source§

fn any(&self) -> &dyn Any

Cast the backend to &dyn Any
source§

fn any_mut(&mut self) -> &mut dyn Any

Cast the backend to &mut dyn Any
source§

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>

Print a string (without a newline) to stderr
source§

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)

Print a string that was create by trace
source§

fn scan_line_stdin(&self) -> Result<Option<String>, String>

Read a line from stdin Read more
source§

fn set_raw_mode(&self, raw_mode: bool) -> Result<(), String>

Set the terminal to raw mode
source§

fn var(&self, name: &str) -> Option<String>

Get an environment variable
source§

fn term_size(&self) -> Result<(usize, usize), String>

Get the size of the terminal
source§

fn file_exists(&self, path: &str) -> bool

Check if a file exists
source§

fn list_dir(&self, path: &str) -> Result<Vec<String>, String>

List the contents of a directory
source§

fn is_file(&self, path: &str) -> Result<bool, String>

Check if a path is a file
source§

fn delete(&self, path: &str) -> Result<(), String>

Delete a file or directory
source§

fn trash(&self, path: &str) -> Result<(), String>

Move a file or directory to the trash
source§

fn read(&self, handle: Handle, count: usize) -> Result<Vec<u8>, String>

Read at most count bytes from a stream
source§

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>

Read from a stream until a delimiter is reached
source§

fn write(&self, handle: Handle, contents: &[u8]) -> Result<(), String>

Write bytes to a stream
source§

fn create_file(&self, path: &Path) -> Result<Handle, String>

Create a file
source§

fn open_file(&self, path: &Path) -> Result<Handle, String>

Open a file
source§

fn file_read_all(&self, path: &Path) -> Result<Vec<u8>, String>

Read all bytes from a file
source§

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>

Sleep the current thread for seconds seconds
source§

fn show_image(&self, image: DynamicImage) -> Result<(), String>

Show an image
source§

fn show_gif(&self, gif_bytes: Vec<u8>) -> Result<(), String>

Show a GIF
source§

fn play_audio(&self, wave_bytes: Vec<u8>) -> Result<(), String>

Play audio from WAV bytes
source§

fn audio_sample_rate(&self) -> u32

Get the audio sample rate
source§

fn stream_audio(&self, f: AudioStreamFn) -> Result<(), String>

Stream audio
source§

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>

Accept a connection with a TCP listener
source§

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>

Get the connection address of a TCP socket
source§

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>

Set the read timeout of a TCP socket
source§

fn tcp_set_write_timeout( &self, handle: Handle, timeout: Option<Duration> ) -> Result<(), String>

Set the write timeout of a TCP socket
source§

fn close(&self, handle: Handle) -> Result<(), String>

Close a stream
source§

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>

Run a command, inheriting standard IO
source§

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>

Run a command and return an IO stream handle
source§

fn change_directory(&self, path: &str) -> Result<(), String>

Change the current directory
source§

fn https_get(&self, request: &str, handle: Handle) -> Result<String, String>

Make an HTTPS request on a TCP socket
source§

fn ffi( &self, file: &str, result_ty: FfiType, name: &str, arg_tys: &[FfiType], args: &[Value] ) -> Result<Value, String>

Call a foreign function interface
source§

fn load_git_module(&self, url: &str) -> Result<PathBuf, String>

Load a git repo as a module Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoSysBackend for T
where T: SysBackend + Send + Sync + 'static,

source§

fn into_sys_backend(self) -> Arc<dyn SysBackend>

Convert to a reference counted system backend
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

source§

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().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more