|
rstd 0.1.0
|
The rstd standard library module, re-exporting all public submodules. More...
Exported Modules | |
| module | rstd.alloc |
| module | rstd.core |
Classes | |
| struct | rstd::io::error::ErrorKind |
| A list specifying general categories of I/O error. More... | |
| struct | rstd::io::error::Error |
| The error type for I/O operations. More... | |
| class | rstd::io::Cursor< T > |
| In-memory reader/writer with a position cursor. More... | |
| struct | rstd::ffi::OsStr |
| An unsized, platform-native string type. More... | |
| class | rstd::ffi::OsString |
| An owned, platform-native string. More... | |
| struct | rstd::time::Instant |
| A measurement of a monotonically nondecreasing clock. More... | |
| struct | rstd::time::SystemTime |
| A measurement of the system clock, useful for talking to external entities like the filesystem or other processes. More... | |
| struct | rstd::path::Path |
An unsized path type, analogous to Rust's std::path::Path. More... | |
| class | rstd::path::PathBuf |
An owned, mutable filesystem path, analogous to Rust's PathBuf. More... | |
| struct | rstd::io::StdoutLock |
| A locked reference to the stdout stream, providing exclusive write access. More... | |
| struct | rstd::io::Stdout |
| Handle to the standard output stream. More... | |
| struct | rstd::io::Stderr |
| Handle to the standard error stream. More... | |
| struct | rstd::io::StdinLock |
| A locked reference to the stdin stream, providing exclusive read access. More... | |
| struct | rstd::io::Stdin |
| Handle to the standard input stream. More... | |
| struct | rstd::io::print< Args > |
| Prints formatted text to stdout. More... | |
| struct | rstd::io::println< Args > |
| Prints formatted text to stdout, followed by a newline. More... | |
| struct | rstd::io::eprint< Args > |
| Prints formatted text to stderr. More... | |
| struct | rstd::io::eprintln< Args > |
| Prints formatted text to stderr, followed by a newline. More... | |
| class | rstd::io::BufReader< R > |
| A buffered wrapper around a reader, reducing the number of read syscalls. More... | |
| class | rstd::io::BufWriter< W > |
| A buffered wrapper around a writer, reducing the number of write syscalls. More... | |
| struct | rstd::io::Empty |
| A reader that always returns EOF and a writer that discards all bytes. More... | |
| struct | rstd::io::Repeat |
| A reader that infinitely yields one byte value. More... | |
| struct | rstd::io::Sink |
| A writer that discards all bytes and never errors. More... | |
| struct | rstd::process::ExitStatus |
| Describes the result of a process after it has terminated. More... | |
| struct | rstd::process::Output |
| The collected output of a finished process. More... | |
| struct | rstd::process::Stdio |
| Describes how to configure a child process's standard I/O stream. More... | |
| struct | rstd::process::ChildStdin |
| A handle to a child process's standard input (write end of pipe). More... | |
| struct | rstd::process::ChildStdout |
| A handle to a child process's standard output (read end of pipe). More... | |
| struct | rstd::process::ChildStderr |
| A handle to a child process's standard error (read end of pipe). More... | |
| struct | rstd::process::Child |
| A child process handle. More... | |
| class | rstd::process::Command |
| A process builder, providing fine-grained control over how a new process should be spawned. More... | |
| class | rstd::thread::Thread |
| A handle to a thread. More... | |
| struct | rstd::thread::ThreadInit |
| Initialization payload for spawning a new thread, containing the handle and start function. More... | |
| class | rstd::thread::ThreadId |
| A unique identifier for a running thread. More... | |
| class | rstd::thread::JoinHandle< T > |
| An owned handle to a thread, which joins the thread on drop. More... | |
| struct | rstd::thread::builder::Builder |
| Thread factory, which can be used in order to configure the properties of a new thread. More... | |
| struct | rstd::io::Read |
| Trait for objects that can be read from. More... | |
| struct | rstd::io::Write |
| Trait for objects that can be written to. More... | |
| struct | rstd::io::SeekFrom |
| Enumeration of possible methods to seek within an I/O object. More... | |
| struct | rstd::io::Seek |
| Trait for types with a notion of current position. More... | |
| struct | rstd::io::BufRead |
| Trait for buffered readers. More... | |
| class | rstd::sync::mpsc::Receiver< T > |
The receiving half of a channel, used to receive messages sent by Sender or SyncSender. More... | |
| class | rstd::sync::mpsc::Sender< T > |
| The sending half of an asynchronous (unbounded) channel. More... | |
| class | rstd::sync::mpsc::SyncSender< T > |
| The sending half of a synchronous (bounded) channel. More... | |
| class | rstd::sync::MutexGuard< T > |
An RAII guard returned by Mutex::lock, providing access to the protected data. More... | |
| class | rstd::sync::Mutex< T > |
| A mutual exclusion primitive useful for protecting shared data. More... | |
| class | rstd::sync::mpsc::mpmc::Sender< C > |
| The sending side. More... | |
| class | rstd::sync::mpsc::mpmc::Receiver< C > |
| The receiving side. More... | |
| struct | rstd::sync::mpsc::mpmc::Entry |
| Represents a thread blocked on a specific channel operation. More... | |
| class | rstd::sync::mpsc::mpmc::SyncWaker |
| A waker that can be shared among threads without locking. More... | |
| struct | rstd::sync::mpsc::mpmc::Operation |
| Identifier associated with an operation by a specific thread on a specific channel. More... | |
| struct | rstd::sync::mpsc::mpmc::Selected |
| Current state of a blocking operation. More... | |
Typedefs | |
| template<typename T > | |
| using | rstd::io::Result = result::Result<T, error::Error> |
| A specialized Result type for I/O operations. | |
Functions | |
| auto | as_str () const noexcept -> ref< str > |
| Returns a string description of this error kind. | |
| static auto | from_raw_os_error (RawOsError code) noexcept -> Error |
| Construct from a raw OS error code (errno / GetLastError). | |
| static auto | from_kind (ErrorKind k) noexcept -> Error |
| Construct from an ErrorKind. | |
| static constexpr auto | new_const (ErrorKind k, const char *msg) noexcept -> Error |
| Construct a static-message error (no allocation). | |
| auto | kind () const noexcept -> ErrorKind |
| Returns the ErrorKind for this error. | |
| auto | raw_os_error () const noexcept -> Option< RawOsError > |
| Returns the raw OS error code if this error originated from the OS. | |
| auto | static_message () const noexcept -> const char * |
| Returns the static message if present (Tag::Message only). | |
| auto | tag () const noexcept -> Tag |
| Returns the internal tag indicating the error representation. | |
| auto | rstd::env::var (const char *key) -> Option< String > |
Fetches the environment variable key from the current process. | |
| void | rstd::env::set_var (const char *key, const char *value) |
Sets the environment variable key to value in the current process. | |
| void | rstd::env::remove_var (const char *key) |
Removes the environment variable key from the current process. | |
| static auto | make () -> OsString |
Creates an empty OsString. | |
| static auto | from (String &&s) -> OsString |
Creates an OsString from a String (zero-cost move on Unix). | |
| static auto | from (ref< str > s) -> OsString |
Creates an OsString by copying a ref<str>. | |
| static auto | from (ref< OsStr > s) -> OsString |
Creates an OsString by copying a ref<OsStr>. | |
| static auto | from_encoded_bytes_unchecked (Vec< u8 > &&bytes) -> OsString |
Creates an OsString from raw bytes without validation. | |
| auto | as_os_str () const noexcept -> ref< OsStr > |
Returns a borrowed ref<OsStr>. | |
| auto | into_string () -> result::Result< String, OsString > |
Attempts to convert to a String. | |
| void | push (ref< OsStr > s) |
Appends an OsStr to this string. | |
| operator ref< OsStr > () const noexcept | |
Implicit conversion to ref<OsStr>. | |
| static auto | now () noexcept -> Instant |
| Returns an instant corresponding to "now". | |
| auto | elapsed () const noexcept -> Duration |
| Returns the amount of time elapsed since this instant was created. | |
| auto | duration_since (Instant other) const noexcept -> Duration |
| Returns the amount of time elapsed from another instant to this one. | |
| auto | checked_add (Duration dur) const noexcept -> Option< Instant > |
| Returns Some(instant) if the addition does not overflow, or None otherwise. | |
| auto | checked_sub (Duration dur) const noexcept -> Option< Instant > |
| Returns Some(instant) if the subtraction does not underflow, or None otherwise. | |
| static auto | now () noexcept -> SystemTime |
| Returns the system time corresponding to "now". | |
| auto | duration_since (SystemTime other) const noexcept -> Result< Duration, Duration > |
Returns the duration since an earlier SystemTime, or an Err if other is later. | |
| auto | elapsed () const noexcept -> Result< Duration, Duration > |
| Returns the elapsed time since this SystemTime was created. | |
| auto | checked_add (Duration dur) const noexcept -> Option< SystemTime > |
| Returns Some(time) if the addition does not overflow, or None otherwise. | |
| auto | checked_sub (Duration dur) const noexcept -> Option< SystemTime > |
| Returns Some(time) if the subtraction does not underflow, or None otherwise. | |
| void | rstd::process::abort () |
| Terminates the process abnormally via the platform abort mechanism. | |
| void | rstd::process::exit (i32 code) |
| Terminates the current process with the specified exit code. | |
| auto | rstd::process::id () -> u32 |
| Returns the OS-assigned process identifier of the current process. | |
| static auto | make () -> PathBuf |
Creates an empty PathBuf. | |
| static auto | from (String &&s) -> PathBuf |
Creates a PathBuf from a String. | |
| static auto | from (ref< str > s) -> PathBuf |
Creates a PathBuf from a ref<str>. | |
| static auto | from (OsString &&s) -> PathBuf |
Creates a PathBuf from an OsString. | |
| static auto | from (const char *s) -> PathBuf |
Creates a PathBuf from a C string. | |
| auto | as_path () const noexcept -> ref< Path > |
Returns a borrowed ref<Path>. | |
| auto | into_os_string () -> OsString |
Consumes the PathBuf and returns the inner OsString. | |
| void | push (ref< Path > component) |
Extends the path with component. | |
| auto | pop () -> bool |
Removes the last component. Returns false if already at root/empty. | |
| auto | join (ref< Path > component) const -> PathBuf |
Creates a new PathBuf by joining this path with a component. | |
| operator ref< Path > () const noexcept | |
Implicit conversion to ref<Path>. | |
| auto | rstd::io::stdout () noexcept -> Stdout |
| Constructs a new handle to the standard output of the current process. | |
| auto | rstd::io::stderr () noexcept -> Stderr |
| Constructs a new handle to the standard error of the current process. | |
| auto | rstd::io::stdin () noexcept -> Stdin |
| Constructs a new handle to the standard input of the current process. | |
| auto | rstd::io::print_fmt (fmt::Arguments args) -> Result< empty > |
Format args and write to stdout (with lock). | |
| auto | rstd::io::eprint_fmt (fmt::Arguments args) -> Result< empty > |
Format args and write to stderr (no lock — panic-safe). | |
| auto | rstd::io::empty_io () noexcept -> Empty |
| Creates a value that implements Read (always EOF), Write (discards), and Seek. | |
| auto | rstd::io::repeat (u8 byte) noexcept -> Repeat |
| Creates a reader that infinitely yields the given byte. | |
| auto | rstd::io::sink () noexcept -> Sink |
| Creates a writer that successfully consumes all data without storing it. | |
|
template<typename R , typename W > requires Impled<R, io::Read> && Impled<W, io::Write> | |
| auto | rstd::io::copy (R &reader, W &writer) -> Result< u64 > |
Copy all bytes from reader into writer. Returns bytes copied. | |
| static constexpr auto | from_code (i32 code) noexcept -> ExitStatus |
| Construct from a raw exit code (process exited normally). | |
| static constexpr auto | from_signal (i32 sig) noexcept -> ExitStatus |
| Construct from a signal number (process was killed). | |
| constexpr auto | success () const noexcept -> bool |
Was termination successful? Returns true if exit code was 0. | |
| constexpr auto | code () const noexcept -> Option< i32 > |
| Returns the exit code if the process exited normally. | |
| constexpr auto | signal () const noexcept -> Option< i32 > |
| Returns the signal number if the process was killed by a signal (Unix). | |
| static constexpr auto | inherit () noexcept -> Stdio |
| The child inherits the corresponding stream from the parent. | |
| static constexpr auto | null () noexcept -> Stdio |
The child's stream is connected to /dev/null. | |
| static constexpr auto | piped () noexcept -> Stdio |
| A new pipe is created between parent and child. | |
| auto | id () const noexcept -> u32 |
| Returns the OS-assigned process ID. | |
| auto | take_stdin () -> Option< ChildStdin > |
| Takes ownership of the child's stdin pipe handle. | |
| auto | take_stdout () -> Option< ChildStdout > |
| Takes ownership of the child's stdout pipe handle. | |
| auto | take_stderr () -> Option< ChildStderr > |
| Takes ownership of the child's stderr pipe handle. | |
| auto | wait () -> io::Result< ExitStatus > |
| Waits for the child to exit and returns its status. | |
| auto | kill () -> io::Result< rstd::empty > |
| Sends SIGKILL to the child process. | |
| auto | wait_with_output () -> io::Result< Output > |
| Waits for the child and collects all remaining stdout/stderr. | |
| static auto | make (const char *program) -> Command |
Creates a new Command for the given program. | |
| auto | arg (const char *a) -> Command & |
| Adds an argument to pass to the program. | |
| auto | env (const char *key, const char *value) -> Command & |
| Sets an environment variable for the child process. | |
| auto | env_remove (const char *key) -> Command & |
| Removes an environment variable for the child process. | |
| auto | env_clear () -> Command & |
| Clears all environment variables for the child process. | |
| auto | current_dir (const char *dir) -> Command & |
| Sets the working directory for the child process. | |
| auto | set_stdin (Stdio s) -> Command & |
| Configures the child process's standard input. | |
| auto | set_stdout (Stdio s) -> Command & |
| Configures the child process's standard output. | |
| auto | set_stderr (Stdio s) -> Command & |
| Configures the child process's standard error. | |
| auto | spawn () -> io::Result< Child > |
| Spawns the child process. | |
| auto | status () -> io::Result< ExitStatus > |
| Executes the command and waits for it to finish, returning the exit status. | |
| auto | output () -> io::Result< Output > |
| Executes the command, waits for it, and collects stdout/stderr. | |
| auto | rstd::thread::try_current () -> Option< Thread > |
| Returns the current thread's handle, or None if unavailable. | |
| auto | rstd::thread::set_current (Thread thread) -> Result< empty, Thread > |
| Sets the handle for the current thread, returning Err if already set or the ID mismatches. | |
| auto | rstd::thread::current () -> Thread |
| Returns a handle to the current thread, lazily initializing if necessary. | |
| auto | rstd::thread::main_thread::get () -> Option< ThreadId > |
| Returns the ThreadId of the main thread, or None if not yet set. | |
| void | rstd::thread::main_thread::set (ThreadId id) |
| Stores the given ThreadId as the main thread identifier. | |
| auto | thread () const -> Thread |
| Extracts a handle to the underlying thread. | |
| auto | join () &&-> Result< ret_t > |
| Waits for the associated thread to finish and returns its result. | |
| auto | is_finished () const -> bool |
| Checks whether the associated thread has finished running. | |
| template<typename F > | |
| auto | rstd::thread::spawn (F &&f) -> io::Result< JoinHandle< mtp::invoke_result_t< F > > > |
| Spawns a new thread, returning a JoinHandle for it. | |
| void | rstd::thread::sleep (rstd::time::Duration dur) |
| Puts the current thread to sleep for at least the specified duration. | |
| void | rstd::thread::yield_now () |
| Cooperatively gives up a timeslice to the OS scheduler. | |
| void | rstd::thread::park () |
Blocks the current thread until its token is made available via unpark. | |
| void | rstd::thread::park_timeout (rstd::time::Duration timeout) |
| Blocks the current thread for at most the specified duration, or until unparked. | |
| void | rstd::thread::unpark (const Thread &thread) |
| Atomically makes the given thread's token available, waking it if parked. | |
| template<typename W > requires Impled<W, Write> | |
| auto | rstd::io::write_all (W &w, const u8 *buf, usize len) -> Result< empty > |
| Write all bytes or return an error. | |
| template<typename R > requires Impled<R, Read> | |
| auto | rstd::io::read_exact (R &r, u8 *buf, usize len) -> Result< empty > |
Read exactly len bytes or return UnexpectedEof. | |
|
template<typename S > requires Impled<S, Seek> | |
| auto | rstd::io::rewind (S &s) -> Result< empty > |
| Seek to the beginning. | |
|
template<typename S > requires Impled<S, Seek> | |
| auto | rstd::io::stream_position (S &s) -> Result< u64 > |
| Return the current stream position. | |
| auto | recv () -> Result< T, empty > |
| Blocks the current thread until a message is received or the channel is disconnected. | |
| auto | try_recv () -> Result< T, empty > |
| Attempts to receive a message without blocking. | |
| auto | send (T msg) -> Result< empty, T > |
| Sends a value on this channel, returning Err(msg) if the receiver has disconnected. | |
| auto | send (T msg) -> Result< empty, T > |
| Sends a value on this channel, blocking if the buffer is full. | |
| auto | try_send (T msg) -> Result< empty, T > |
| Attempts to send a value without blocking. | |
| template<typename T > | |
| auto | rstd::sync::mpsc::channel () -> rstd::tuple< Sender< T >, Receiver< T > > |
| Creates an asynchronous (unbounded) channel, returning the sender and receiver halves. | |
| template<typename T > | |
| auto | rstd::sync::mpsc::sync_channel (usize bound) -> rstd::tuple< SyncSender< T >, Receiver< T > > |
| Creates a synchronous (bounded) channel with the given buffer capacity. | |
| template<typename C > | |
| auto | rstd::sync::mpsc::mpmc::new_counter (C chan) -> rstd::tuple< Sender< C >, Receiver< C > > |
| Wraps a channel into the reference counter. | |
The rstd standard library module, re-exporting all public submodules.