Skip to main content

SharedSystem

Struct SharedSystem 

Source
pub struct SharedSystem<S>(/* private fields */);
๐Ÿ‘ŽDeprecated since 0.13.0:

use Concurrent instead

Expand description

System shared by a reference counter.

A SharedSystem is a reference-counted container of a System instance accompanied with an internal state for supporting asynchronous interactions with the system. As it is reference-counted, cloning a SharedSystem instance only increments the reference count without cloning the backing system instance. This behavior allows calling SharedSystemโ€™s methods concurrently from different async tasks that each have a SharedSystem instance sharing the same state.

SharedSystem implements System by delegating to the contained system instance of type S. You should avoid calling some of the System methods, however. Prefer async functions provided by SharedSystem (e.g., read_async) over raw system functions (e.g., read).

The following example illustrates how multiple concurrent tasks are run in a single-threaded pool:

let system = SharedSystem::new(VirtualSystem::new());
let system2 = system.clone();
let system3 = system.clone();
let (reader, writer) = system.pipe().unwrap();
let mut executor = futures_executor::LocalPool::new();

// We add a task that tries to read from the pipe, but nothing has been
// written to it, so the task is stalled.
let read_task = executor.spawner().spawn_local_with_handle(async move {
    let mut buffer = [0; 1];
    system.read_async(reader, &mut buffer).await.unwrap();
    buffer[0]
});
executor.run_until_stalled();

// Let's add a task that writes to the pipe.
executor.spawner().spawn_local(async move {
    system2.write_all(writer, &[123]).await.unwrap();
});
executor.run_until_stalled();

// The write task has written a byte to the pipe, but the read task is still
// stalled. We need to wake it up by calling `select`.
system3.select(false).unwrap();

// Now the read task can proceed to the end.
let number = executor.run_until(read_task.unwrap());
assert_eq!(number, 123);

Implementationsยง

Sourceยง

impl<S> SharedSystem<S>

Source

pub fn new(system: S) -> Self

Creates a new shared system.

Source

pub async fn read_async(&self, fd: Fd, buffer: &mut [u8]) -> Result<usize>
where S: Fcntl + Read,

Reads from the file descriptor.

This function waits for one or more bytes to be available for reading. If successful, returns the number of bytes read.

Source

pub async fn write_all(&self, fd: Fd, buffer: &[u8]) -> Result<usize>
where S: Fcntl + Write,

Writes to the file descriptor.

This function calls write repeatedly until the whole buffer is written to the FD. If the buffer is empty, write is not called at all, so any error that would be returned from write is not returned.

This function silently ignores signals that may interrupt writes.

Source

pub async fn print_error(&self, message: &str)
where S: Fcntl + Write,

Convenience function for printing a message to the standard error

Source

pub async fn wait_until(&self, target: Instant)
where S: Clock,

Waits until the specified time point.

Source

pub async fn wait_for_signals(&self) -> Rc<[Number]>

Waits for some signals to be delivered to this process.

Before calling this function, you need to set the signal disposition to Catch. Without doing so, this function cannot detect the receipt of the signals.

Returns an array of signals that were caught.

If this SharedSystem is part of an Env, you should call Env::wait_for_signals rather than calling this function directly so that the trap set can remember the caught signal.

Source

pub async fn wait_for_signal(&self, signal: Number)

Waits for a signal to be delivered to this process.

Before calling this function, you need to set the signal disposition to Catch. Without doing so, this function cannot detect the receipt of the signal.

If this SharedSystem is part of an Env, you should call Env::wait_for_signal rather than calling this function directly so that the trap set can remember the caught signal.

Source

pub fn select(&self, poll: bool) -> Result<()>
where S: Select + CaughtSignals + Clock,

Waits for a next event to occur.

This function calls Select::select with arguments computed from the current internal state of the SharedSystem. It will wake up tasks waiting for the file descriptor to be ready in read_async and write_all or for a signal to be caught in wait_for_signal. If no tasks are woken for FDs or signals and poll is false, this function will block until the first task waiting for a specific time point is woken.

If poll is true, this function does not block, so it may not wake up any tasks.

This function may wake up a task even if the condition it is expecting has not yet been met.

Source

pub async fn select_async(&self) -> Result<()>
where S: Select + CaughtSignals + Clock,

Waits for a next event to occur.

This function calls Select::select with arguments computed from the current internal state of the SharedSystem. It will wake up tasks waiting for the file descriptor to be ready in read_async and write_all or for a signal to be caught in wait_for_signal. If no tasks are woken for FDs or signals, this function simulates blocking by returning Pending from the returned future until the first task waiting for a specific time point is woken.

This function may wake up a task even if the condition it is expecting has not yet been met.

Source

pub fn new_child_process(&self) -> Result<ChildProcessStarter<S>>
where S: Fork,

Creates a new child process.

See Fork::new_child_process for details.

Trait Implementationsยง

Sourceยง

impl<T: CaughtSignals> CaughtSignals for SharedSystem<T>

Delegates CaughtSignals methods to the contained implementor.

Sourceยง

fn caught_signals(&self) -> Vec<Number>

Returns signals this process has caught, if any. Read more
Sourceยง

impl<T: Chdir> Chdir for SharedSystem<T>

Delegates Chdir methods to the contained implementor.

Sourceยง

fn chdir(&self, path: &CStr) -> Result<()>

Changes the working directory.
Sourceยง

impl<T: Clock> Clock for SharedSystem<T>

Delegates Time methods to the contained implementor.

Sourceยง

fn now(&self) -> Instant

Returns the current time.
Sourceยง

impl<S> Clone for SharedSystem<S>

Sourceยง

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl<T: Close> Close for SharedSystem<T>

Sourceยง

fn close(&self, fd: Fd) -> Result<()>

Closes a file descriptor. Read more
Sourceยง

impl<S: Debug> Debug for SharedSystem<S>

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Sourceยง

impl<T: Dup> Dup for SharedSystem<T>

Delegates Dup methods to the contained implementor.

Sourceยง

fn dup(&self, from: Fd, to_min: Fd, flags: EnumSet<FdFlag>) -> Result<Fd>

Duplicates a file descriptor. Read more
Sourceยง

fn dup2(&self, from: Fd, to: Fd) -> Result<Fd>

Duplicates a file descriptor. Read more
Sourceยง

impl<T: Exec> Exec for SharedSystem<T>

Delegates Exec methods to the contained implementor.

Sourceยง

fn execve( &self, path: &CStr, args: &[CString], envs: &[CString], ) -> impl Future<Output = Result<Infallible>> + use<T>

Replaces the current process with an external utility. Read more
Sourceยง

impl<T: Exit> Exit for SharedSystem<T>

Delegates Exit methods to the contained implementor.

Sourceยง

fn exit( &self, exit_status: ExitStatus, ) -> impl Future<Output = Infallible> + use<T>

Terminates the current process. Read more
Sourceยง

impl<T: Fcntl> Fcntl for SharedSystem<T>

Delegates Fcntl methods to the contained implementor.

Sourceยง

fn ofd_access(&self, fd: Fd) -> Result<OfdAccess>

Returns the open file description access mode.
Sourceยง

fn get_and_set_nonblocking(&self, fd: Fd, nonblocking: bool) -> Result<bool>

Gets and sets the non-blocking mode for the open file description. Read more
Sourceยง

fn fcntl_getfd(&self, fd: Fd) -> Result<EnumSet<FdFlag>>

Returns the attributes for the file descriptor.
Sourceยง

fn fcntl_setfd(&self, fd: Fd, flags: EnumSet<FdFlag>) -> Result<()>

Sets attributes for the file descriptor.
Sourceยง

impl<T: Fstat> Fstat for SharedSystem<T>

Delegates Fstat methods to the contained implementor.

Sourceยง

type Stat = <T as Fstat>::Stat

Metadata type returned by fstat and fstatat
Sourceยง

fn fstat(&self, fd: Fd) -> Result<Self::Stat>

Retrieves metadata of a file. Read more
Sourceยง

fn fstatat( &self, dir_fd: Fd, path: &CStr, follow_symlinks: bool, ) -> Result<Self::Stat>

Retrieves metadata of a file. Read more
Sourceยง

fn is_directory(&self, path: &CStr) -> bool

Whether there is a directory at the specified path.
Sourceยง

fn fd_is_pipe(&self, fd: Fd) -> bool

Tests if a file descriptor is a pipe.
Sourceยง

impl<T: GetCwd> GetCwd for SharedSystem<T>

Delegates GetCwd methods to the contained implementor.

Sourceยง

fn getcwd(&self) -> Result<PathBuf>

Returns the current working directory path.
Sourceยง

impl<T: GetPid> GetPid for SharedSystem<T>

Delegates GetPid methods to the contained implementor.

Sourceยง

fn getsid(&self, pid: Pid) -> Result<Pid>

Returns the session ID of the specified process. Read more
Sourceยง

fn getpid(&self) -> Pid

Returns the process ID of the current process. Read more
Sourceยง

fn getppid(&self) -> Pid

Returns the process ID of the parent process. Read more
Sourceยง

fn getpgrp(&self) -> Pid

Returns the process group ID of the current process. Read more
Sourceยง

impl<T: GetPw> GetPw for SharedSystem<T>

Delegates GetPw methods to the contained implementor.

Sourceยง

fn getpwnam_dir(&self, name: &CStr) -> Result<Option<PathBuf>>

Returns the home directory path of the given user. Read more
Sourceยง

impl<T: GetRlimit> GetRlimit for SharedSystem<T>

Delegates GetRlimit methods to the contained implementor.

Sourceยง

fn getrlimit(&self, resource: Resource) -> Result<LimitPair>

Returns the limits for the specified resource. Read more
Sourceยง

impl<T: Sigaction> GetSigaction for SharedSystem<T>

Delegates GetSigaction methods to the contained implementor.

Sourceยง

fn get_sigaction(&self, signal: Number) -> Result<Disposition>

Gets the disposition for a signal. Read more
Sourceยง

impl<T: GetUid> GetUid for SharedSystem<T>

Delegates GetUid methods to the contained implementor.

Sourceยง

fn getuid(&self) -> Uid

Returns the real user ID of the current process.
Sourceยง

fn geteuid(&self) -> Uid

Returns the effective user ID of the current process.
Sourceยง

fn getgid(&self) -> Gid

Returns the real group ID of the current process.
Sourceยง

fn getegid(&self) -> Gid

Returns the effective group ID of the current process.
Sourceยง

impl<T: IsExecutableFile> IsExecutableFile for SharedSystem<T>

Delegates IsExecutableFile methods to the contained implementor.

Sourceยง

fn is_executable_file(&self, path: &CStr) -> bool

Whether there is an executable regular file at the specified path.
Sourceยง

impl<T: Isatty> Isatty for SharedSystem<T>

Delegates Isatty methods to the contained implementor.

Sourceยง

fn isatty(&self, fd: Fd) -> bool

Tests if a file descriptor is associated with a terminal device. Read more
Sourceยง

impl<T: Open> Open for SharedSystem<T>

Sourceยง

fn open( &self, path: &CStr, access: OfdAccess, flags: EnumSet<OpenFlag>, mode: Mode, ) -> impl Future<Output = Result<Fd>> + use<T>

Opens a file descriptor. Read more
Sourceยง

fn open_tmpfile(&self, parent_dir: &Path) -> Result<Fd>

Opens a file descriptor associated with an anonymous temporary file. Read more
Sourceยง

fn fdopendir(&self, fd: Fd) -> Result<impl Dir + use<T>>

Opens a directory for enumerating entries. Read more
Sourceยง

fn opendir(&self, path: &CStr) -> Result<impl Dir + use<T>>

Opens a directory for enumerating entries. Read more
Sourceยง

impl<T: Pipe> Pipe for SharedSystem<T>

Delegates Pipe methods to the contained implementor.

Sourceยง

fn pipe(&self) -> Result<(Fd, Fd)>

Creates an unnamed pipe. Read more
Sourceยง

impl<T: Read> Read for SharedSystem<T>

Delegates Read methods to the contained implementor.

Sourceยง

fn read<'a>( &self, fd: Fd, buffer: &'a mut [u8], ) -> impl Future<Output = Result<usize>> + use<'a, T>

Reads from the file descriptor. Read more
Sourceยง

impl<T: Seek> Seek for SharedSystem<T>

Delegates Seek methods to the contained implementor.

Sourceยง

fn lseek(&self, fd: Fd, position: SeekFrom) -> Result<u64>

Moves the position of the open file description. Read more
Sourceยง

impl<T: Select> Select for SharedSystem<T>

Delegates Select methods to the contained implementor.

Sourceยง

fn select<'a>( &self, readers: &'a mut Vec<Fd>, writers: &'a mut Vec<Fd>, timeout: Option<Duration>, signal_mask: Option<&[Number]>, ) -> impl Future<Output = Result<c_int>> + use<'a, T>

Waits for a next event. Read more
Sourceยง

impl<T: SendSignal> SendSignal for SharedSystem<T>

Delegates SendSignal methods to the contained implementor.

Sourceยง

fn kill( &self, target: Pid, signal: Option<Number>, ) -> impl Future<Output = Result<()>> + use<T>

Sends a signal. Read more
Sourceยง

fn raise(&self, signal: Number) -> impl Future<Output = Result<()>> + use<T>

Sends a signal to the current process. Read more
Sourceยง

impl<T: SetPgid> SetPgid for SharedSystem<T>

Delegates SetPgid methods to the contained implementor.

Sourceยง

fn setpgid(&self, pid: Pid, pgid: Pid) -> Result<()>

Modifies the process group ID of a process. Read more
Sourceยง

impl<T: SetRlimit> SetRlimit for SharedSystem<T>

Delegates SetRlimit methods to the contained implementor.

Sourceยง

fn setrlimit(&self, resource: Resource, limits: LimitPair) -> Result<()>

Sets the limits for the specified resource. Read more
Sourceยง

impl<T: ShellPath> ShellPath for SharedSystem<T>

Delegates ShellPath methods to the contained implementor.

Sourceยง

fn shell_path(&self) -> CString

Returns the path to the shell executable. Read more
Sourceยง

impl<T: Sigaction> Sigaction for SharedSystem<T>

Delegates Sigaction methods to the contained implementor.

Sourceยง

fn sigaction(&self, signal: Number, action: Disposition) -> Result<Disposition>

Gets and sets the disposition for a signal. Read more
Sourceยง

impl<T: Sigmask> Sigmask for SharedSystem<T>

Delegates Sigmask methods to the contained implementor.

Sourceยง

fn sigmask( &self, op: Option<(SigmaskOp, &[Number])>, old_mask: Option<&mut Vec<Number>>, ) -> impl Future<Output = Result<()>> + use<T>

Gets and/or sets the signal blocking mask. Read more
Sourceยง

impl<S: Signals + Sigmask + Sigaction> SignalSystem for SharedSystem<S>

Sourceยง

fn get_disposition(&self, signal: Number) -> Result<Disposition>

Returns the current disposition for a signal. Read more
Sourceยง

fn set_disposition( &self, signal: Number, disposition: Disposition, ) -> impl Future<Output = Result<Disposition>> + use<S>

Sets how a signal is handled. Read more
Sourceยง

impl<T: Signals> Signals for SharedSystem<T>

Delegates Signals methods to the contained implementor.

Sourceยง

const SIGABRT: Number = T::SIGABRT

The signal number for SIGABRT
Sourceยง

const SIGALRM: Number = T::SIGALRM

The signal number for SIGALRM
Sourceยง

const SIGBUS: Number = T::SIGBUS

The signal number for SIGBUS
Sourceยง

const SIGCHLD: Number = T::SIGCHLD

The signal number for SIGCHLD
Sourceยง

const SIGCLD: Option<Number> = T::SIGCLD

The signal number for SIGCLD, if available on the system
Sourceยง

const SIGCONT: Number = T::SIGCONT

The signal number for SIGCONT
Sourceยง

const SIGEMT: Option<Number> = T::SIGEMT

The signal number for SIGEMT, if available on the system
Sourceยง

const SIGFPE: Number = T::SIGFPE

The signal number for SIGFPE
Sourceยง

const SIGHUP: Number = T::SIGHUP

The signal number for SIGHUP
Sourceยง

const SIGILL: Number = T::SIGILL

The signal number for SIGILL
Sourceยง

const SIGINFO: Option<Number> = T::SIGINFO

The signal number for SIGINFO, if available on the system
Sourceยง

const SIGINT: Number = T::SIGINT

The signal number for SIGINT
Sourceยง

const SIGIO: Option<Number> = T::SIGIO

The signal number for SIGIO, if available on the system
Sourceยง

const SIGIOT: Number = T::SIGIOT

The signal number for SIGIOT
Sourceยง

const SIGKILL: Number = T::SIGKILL

The signal number for SIGKILL
Sourceยง

const SIGLOST: Option<Number> = T::SIGLOST

The signal number for SIGLOST, if available on the system
Sourceยง

const SIGPIPE: Number = T::SIGPIPE

The signal number for SIGPIPE
Sourceยง

const SIGPOLL: Option<Number> = T::SIGPOLL

The signal number for SIGPOLL, if available on the system
Sourceยง

const SIGPROF: Number = T::SIGPROF

The signal number for SIGPROF
Sourceยง

const SIGPWR: Option<Number> = T::SIGPWR

The signal number for SIGPWR, if available on the system
Sourceยง

const SIGQUIT: Number = T::SIGQUIT

The signal number for SIGQUIT
Sourceยง

const SIGSEGV: Number = T::SIGSEGV

The signal number for SIGSEGV
Sourceยง

const SIGSTKFLT: Option<Number> = T::SIGSTKFLT

The signal number for SIGSTKFLT, if available on the system
Sourceยง

const SIGSTOP: Number = T::SIGSTOP

The signal number for SIGSTOP
Sourceยง

const SIGSYS: Number = T::SIGSYS

The signal number for SIGSYS
Sourceยง

const SIGTERM: Number = T::SIGTERM

The signal number for SIGTERM
Sourceยง

const SIGTHR: Option<Number> = T::SIGTHR

The signal number for SIGTHR, if available on the system
Sourceยง

const SIGTRAP: Number = T::SIGTRAP

The signal number for SIGTRAP
Sourceยง

const SIGTSTP: Number = T::SIGTSTP

The signal number for SIGTSTP
Sourceยง

const SIGTTIN: Number = T::SIGTTIN

The signal number for SIGTTIN
Sourceยง

const SIGTTOU: Number = T::SIGTTOU

The signal number for SIGTTOU
Sourceยง

const SIGURG: Number = T::SIGURG

The signal number for SIGURG
Sourceยง

const SIGUSR1: Number = T::SIGUSR1

The signal number for SIGUSR1
Sourceยง

const SIGUSR2: Number = T::SIGUSR2

The signal number for SIGUSR2
Sourceยง

const SIGVTALRM: Number = T::SIGVTALRM

The signal number for SIGVTALRM
Sourceยง

const SIGWINCH: Number = T::SIGWINCH

The signal number for SIGWINCH
Sourceยง

const SIGXCPU: Number = T::SIGXCPU

The signal number for SIGXCPU
Sourceยง

const SIGXFSZ: Number = T::SIGXFSZ

The signal number for SIGXFSZ
Sourceยง

fn sigrt_range(&self) -> Option<RangeInclusive<Number>>

Returns the range of real-time signals supported by the system. Read more
Sourceยง

fn iter_sigrt(&self) -> impl DoubleEndedIterator<Item = Number> + use<T>

Returns an iterator over all real-time signals supported by the system. Read more
Sourceยง

fn validate_signal(&self, number: RawNumber) -> Option<(Name, Number)>

Tests if a signal number is valid and returns its name and number. Read more
Sourceยง

const NAMED_SIGNALS: &'static [(&'static str, Option<Number>)] = _

List of all signal names and their numbers, excluding real-time signals Read more
Sourceยง

fn to_signal_number<N: Into<RawNumber>>(&self, number: N) -> Option<Number>

Tests if a signal number is valid and returns its signal number. Read more
Sourceยง

fn sig2str<N: Into<RawNumber>>(&self, signal: N) -> Option<Cow<'static, str>>

Converts a signal number to its string representation. Read more
Sourceยง

fn str2sig(&self, name: &str) -> Option<Number>

Converts a string representation of a signal to its signal number. Read more
Sourceยง

fn signal_name_from_number(&self, number: Number) -> Name

Returns the signal name for the signal number. Read more
Sourceยง

fn signal_number_from_name(&self, name: Name) -> Option<Number>

Gets the signal number from the signal name. Read more
Sourceยง

impl<T: Sysconf> Sysconf for SharedSystem<T>

Delegates Sysconf methods to the contained implementor.

Sourceยง

fn confstr_path(&self) -> Result<UnixString>

Returns the standard $PATH value where all standard utilities are expected to be found. Read more
Sourceยง

impl<T: TcGetPgrp> TcGetPgrp for SharedSystem<T>

Delegates TcGetPgrp methods to the contained implementor.

Sourceยง

fn tcgetpgrp(&self, fd: Fd) -> Result<Pid>

Returns the current foreground process group ID. Read more
Sourceยง

impl<T: TcSetPgrp> TcSetPgrp for SharedSystem<T>

Delegates TcSetPgrp methods to the contained implementor.

Sourceยง

fn tcsetpgrp( &self, fd: Fd, pgid: Pid, ) -> impl Future<Output = Result<()>> + use<T>

Switches the foreground process group. Read more
Sourceยง

impl<T: Times> Times for SharedSystem<T>

Delegates Times methods to the contained implementor.

Sourceยง

fn times(&self) -> Result<CpuTimes>

Returns the consumed CPU time statistics. Read more
Sourceยง

impl<T: Umask> Umask for SharedSystem<T>

Delegates Umask methods to the contained implementor.

Sourceยง

fn umask(&self, new_mask: Mode) -> Mode

Gets and sets the file creation mode mask. Read more
Sourceยง

impl<T: Wait> Wait for SharedSystem<T>

Delegates Wait methods to the contained implementor.

Sourceยง

fn wait(&self, target: Pid) -> Result<Option<(Pid, ProcessState)>>

Reports updated status of a child process. Read more
Sourceยง

impl<T: Write> Write for SharedSystem<T>

Delegates Write methods to the contained implementor.

Sourceยง

fn write<'a>( &self, fd: Fd, buffer: &'a [u8], ) -> impl Future<Output = Result<usize>> + use<'a, T>

Writes to the file descriptor. 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> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> DynClone for T
where T: Clone,

Sourceยง

fn __clone_box(&self, _: Private) -> *mut ()

Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

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

Sourceยง

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>,

Sourceยง

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.