Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 4.08 KB

README.md

File metadata and controls

47 lines (37 loc) · 4.08 KB

happy-rustyDocs


happy-rusty

Interfaces

Interface Description
None Represents the absence of a value, as a specialized Option type. The type parameter is set to never because None does not hold a value.
Option Type Option represents an optional value: every Option is either Some and contains a value, or None, and does not. This interface includes methods that act on the Option type, similar to Rust's Option enum.
Result The Result type is used for returning and propagating errors. It is an enum with the variants, Ok(T), representing success and containing a value, and Err(E), representing error and containing an error value. This interface includes methods that act on the Result type, similar to Rust's Result enum.

Type Aliases

Type alias Description
AsyncIOResult Represents an asynchronous I/O operation that yields a Result<T, Error>. This is a promise that resolves to Ok(T) if the I/O operation was successful, or Err(Error) if there was an error.
AsyncOption Represents an asynchronous operation that yields an Option<T>. This is a promise that resolves to either Some(T) if the value is present, or None if the value is absent.
AsyncResult Represents an asynchronous operation that yields a Result<T, E>. This is a promise that resolves to Ok(T) if the operation was successful, or Err(E) if there was an error.
AsyncVoidIOResult VoidIOResult wrapped by Promise.
AsyncVoidResult VoidResult<E> wrapped by Promise.
IOResult Represents a synchronous operation that yields a Result<T, Error>. This is a result that is either Ok(T) if the operation was successful, or Err(Error) if there was an error.
VoidIOResult Similar to Rust's Result<(), Error>.
VoidResult Similar to Rust's Result<(), E>.

Variables

Variable Description
None A constant representing the None case of an Option, indicating the absence of a value. This constant is frozen to ensure it is immutable and cannot be altered, preserving the integrity of None throughout the application.
RESULT_FALSE Result constant for false. Can be used anywhere due to immutability.
RESULT_TRUE Result constant for true. Can be used anywhere due to immutability.
RESULT_VOID Result constant for void or ().
RESULT_ZERO Result constant for 0. Can be used anywhere due to immutability.

Functions

Function Description
Err Creates a Result<T, E> representing a failed outcome containing an error. This function is used to construct a Result that signifies the operation failed by containing the error E.
Ok Creates a Result<T, E> representing a successful outcome containing a value. This function is used to construct a Result that signifies the operation was successful by containing the value T.
Some Creates an Option<T> representing the presence of a value. This function is typically used to construct an Option that contains a value, indicating that the operation yielding the value was successful.
isOption Checks if a value is an Option.
isResult Checks if a value is a Result.
promiseToAsyncResult Converts a Promise to a Result type, capturing the resolved value in an Ok, or the error in an Err. This allows for promise-based asynchronous operations to be handled in a way that is more in line with the Result pattern.