oku_fs::fs

Struct OkuFs

Source
pub struct OkuFs {
    pub replica_sender: Sender<()>,
    /* private fields */
}
Expand description

An instance of an Oku file system.

The OkuFs struct is the primary interface for interacting with an Oku file system.

Fields§

§replica_sender: Sender<()>

A watcher for when replicas are created, deleted, or imported.

Implementations§

Source§

impl OkuFs

Source

pub async fn announce_replica(&self, namespace_id: NamespaceId) -> Result<()>

Announces a writable replica to the Mainline DHT.

§Arguments
  • namespace_id - The ID of the replica to announce.
Source

pub async fn announce_home_replica(&self) -> Result<NamespaceId>

Announce the home replica

Source

pub async fn announce_replicas(&self) -> Result<()>

Announces all writable replicas to the Mainline DHT.

Source§

impl OkuFs

Source

pub async fn get_author(&self) -> Result<Author>

Obtain the private key of the node’s authorship credentials.

§Return

The private key of the node’s authorship credentials.

Source

pub async fn start() -> Result<Self>

Starts an instance of an Oku file system. In the background, an Iroh node is started if none is running, or is connected to if one is already running.

§Arguments
  • handle - If compiling with the fuse feature, a Tokio runtime handle is required.
§Returns

A running instance of an Oku file system.

Source

pub async fn shutdown(self) -> Result<()>

Shuts down the Oku file system.

Source

pub async fn get_oldest_timestamp(&self) -> Result<u64>

Determines the oldest timestamp of a file entry in any replica stored locally.

§Returns

The oldest timestamp in any local replica, in microseconds from the Unix epoch.

Source

pub async fn get_newest_timestamp(&self) -> Result<u64>

Determines the latest timestamp of a file entry in any replica stored locally.

§Returns

The latest timestamp in any local replica, in microseconds from the Unix epoch.

Source

pub async fn get_size(&self) -> Result<u64>

Determines the size of the file system.

§Returns

The total size, in bytes, of the files in every replica stored locally.

Source§

impl OkuFs

Source

pub async fn read_directory( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<Vec<(Entry, Bytes)>>

Reads the contents of the files in a directory.

§Arguments
  • namespace_id - The ID of the replica containing the folder.

  • path - The folder whose contents will be read.

§Returns

A list of file entries and the corresponding content as bytes.

Source

pub async fn read_directory_from_replica_handle( &self, document: Doc, path: PathBuf, ) -> Result<Vec<(Entry, Bytes)>>

Reads the contents of the files in a directory.

§Arguments
  • document - A handle to the replica containing the folder.

  • path - The folder whose contents will be read.

§Returns

A list of file entries and the corresponding content as bytes.

Source

pub async fn move_directory( &self, from_namespace_id: NamespaceId, from_path: PathBuf, to_namespace_id: NamespaceId, to_path: PathBuf, ) -> Result<(Vec<Hash>, usize)>

Moves a directory by copying it to a new location and deleting the original.

§Arguments
  • from_namespace_id - The ID of the replica containing the directory to move.

  • to_namespace_id - The ID of the replica to move the directory to.

  • from_path - The path of the directory to move.

  • to_path - The path to move the directory to.

§Returns

A tuple containing the list of file hashes for files at their new destinations, and the total number of replica entries deleted during the operation.

Source

pub async fn delete_directory( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<usize>

Deletes a directory and all its contents.

§Arguments
  • namespace_id - The ID of the replica containing the directory to delete.

  • path - The path of the directory to delete.

§Returns

The number of entries deleted.

Source

pub async fn get_oldest_timestamp_in_folder( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<u64>

Determines the oldest timestamp of a file entry in a folder.

§Arguments
  • namespace_id - The ID of the replica containing the folder.

  • path - The folder whose oldest timestamp is to be determined.

§Returns

The oldest timestamp of any file descending from this folder, in microseconds from the Unix epoch.

Source

pub async fn get_newest_timestamp_in_folder( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<u64>

Determines the latest timestamp of a file entry in a folder.

§Arguments
  • namespace_id - The ID of the replica containing the folder.

  • path - The folder whose latest timestamp is to be determined.

§Returns

The latest timestamp of any file descending from this folder, in microseconds from the Unix epoch.

Source

pub async fn get_folder_size( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<u64>

Determines the size of a folder.

§Arguments
  • namespace_id - The ID of the replica containing the folder.

  • path - The path to the folder within the replica.

§Returns

The total size, in bytes, of the files descending from this folder.

Source

pub async fn fetch_directory_with_ticket( &self, ticket: &DocTicket, path: PathBuf, ) -> Result<Vec<(Entry, Bytes)>>

Join a swarm to fetch the latest version of a directory and save it to the local machine.

§Arguments
  • ticket - A ticket for the replica containing the directory to retrieve.

  • path - The path to the directory to retrieve.

§Returns

The content of the files in the directory.

Source§

impl OkuFs

Source

pub async fn list_files( &self, namespace_id: NamespaceId, path: Option<PathBuf>, ) -> Result<Vec<Entry>>

Lists files in a replica.

§Arguments
  • namespace_id - The ID of the replica to list files in.

  • path - An optional path within the replica.

§Returns

A list of files in the replica.

Source

pub async fn create_or_modify_file( &self, namespace_id: NamespaceId, path: PathBuf, data: impl Into<Bytes>, ) -> Result<Hash>

Creates a file (if it does not exist) or modifies an existing file.

§Arguments
  • namespace_id - The ID of the replica containing the file to create or modify.

  • path - The path of the file to create or modify.

  • data - The data to write to the file.

§Returns

The hash of the file.

Source

pub async fn delete_file( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<usize>

Deletes a file.

§Arguments
  • namespace_id - The ID of the replica containing the file to delete.

  • path - The path of the file to delete.

§Returns

The number of entries deleted in the replica, which should be 1 if the file was successfully deleted.

Source

pub async fn get_entry( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<Entry>

Gets an Iroh entry for a file.

§Arguments
  • namespace_id - The ID of the replica containing the file.

  • path - The path of the file.

§Returns

The entry representing the file.

Source

pub async fn get_oldest_entry_timestamp( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<u64>

Determines the oldest timestamp of a file.

§Arguments
  • namespace_id - The ID of the replica containing the file.

  • path - The path to the file.

§Returns

The timestamp, in microseconds from the Unix epoch, of the oldest entry in the file.

Source

pub async fn read_file( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<Bytes>

Reads a file.

§Arguments
  • namespace_id - The ID of the replica containing the file to read.

  • path - The path of the file to read.

§Returns

The data read from the file.

Source

pub async fn read_file_from_replica_handle( &self, document: Doc, path: PathBuf, ) -> Result<Bytes>

Reads a file.

§Arguments
  • document - A handle to the replica containing the file to read.

  • path - The path of the file to read.

§Returns

The data read from the file.

Source

pub async fn move_file( &self, from_namespace_id: NamespaceId, from_path: PathBuf, to_namespace_id: NamespaceId, to_path: PathBuf, ) -> Result<(Hash, usize)>

Moves a file by copying it to a new location and deleting the original.

§Arguments
  • from_namespace_id - The ID of the replica containing the file to move.

  • to_namespace_id - The ID of the replica to move the file to.

  • from_path - The path of the file to move.

  • to_path - The path to move the file to.

§Returns

A tuple containing the hash of the file at the new destination and the number of replica entries deleted during the operation, which should be 1 if the file at the original path was deleted.

Source

pub async fn fetch_file( &self, namespace_id: NamespaceId, path: PathBuf, ) -> Result<Bytes>

Retrieve a file locally after attempting to retrieve the latest version from the Internet.

§Arguments
  • namespace_id - The ID of the replica containing the file to retrieve.

  • path - The path to the file to retrieve.

§Returns

The data read from the file.

Source

pub async fn fetch_file_with_ticket( &self, ticket: &DocTicket, path: PathBuf, ) -> Result<Bytes>

Join a swarm to fetch the latest version of a file and save it to the local machine.

§Arguments
  • ticket - A ticket for the replica containing the file to retrieve.

  • path - The path to the file to retrieve.

§Returns

The data read from the file.

Source§

impl OkuFs

Source

pub async fn default_author(&self) -> Result<AuthorId>

Retrieve the content authorship ID used by the node.

§Returns

The content authorship ID used by the node.

Source

pub async fn export_user(&self) -> Option<ExportedUser>

Exports the local Oku user’s credentials.

§Returns

The local Oku user’s credentials, containing sensitive information.

Source

pub async fn import_user(&self, exported_user: ExportedUser) -> Result<()>

Imports Oku user credentials that were exported from another node.

§Arguments
  • exported_user - Oku user credentials, which contain sensitive information.
Source

pub async fn export_user_toml(&self) -> Result<String>

Exports the local Oku user’s credentials in TOML format.

§Returns

The local Oku user’s credentials, containing sensitive information.

Source

pub async fn import_user_toml(&self, exported_user_toml: String) -> Result<()>

Imports Oku user credentials that were exported from another node.

§Arguments
  • exported_user - Oku user credentials, encoded in TOML format. They contain sensitive information.
Source

pub async fn home_replica(&self) -> Option<NamespaceId>

Retrieve the home replica of the Oku user.

§Returns

The home replica of the Oku user.

Source

pub fn set_home_replica(&self, home_replica: Option<NamespaceId>) -> Result<()>

Set the home replica of the Oku user.

§Arguments
  • home_replica - The ID of the intended new home replica.
Source

pub async fn posts(&self) -> Option<Vec<OkuPost>>

Retrieves the OkuNet posts by the local user, if any.

§Returns

A list of the OkuNet posts by the local user.

Source

pub async fn all_posts_with_tag(&self, tag: String) -> Vec<OkuPost>

Retrieves all posts containing a given tag, whether they are authored by the local user or an OkuNet user.

§Arguments
  • tag - A tag.
§Returns

A list of OkuNet posts with the given tag.

Source

pub async fn all_tags(&self) -> HashSet<String>

Retrieves the set of all tags that appear in posts authored by the local user or an OkuNet user.

§Returns

All tags that appear across all posts on the local machine.

Source

pub async fn post(&self, path: PathBuf) -> Result<OkuPost>

Retrieves an OkuNet post authored by the local user using its path.

§Arguments
  • path - A path to a post in the user’s home replica.
§Returns

The OkuNet post at the given path.

Source

pub async fn identity(&self) -> Option<OkuIdentity>

Retrieves the OkuNet identity of the local user.

§Returns

The local user’s OkuNet identity, if they have one.

Source

pub async fn set_identity(&self, identity: OkuIdentity) -> Result<Hash>

Replaces the current OkuNet identity of the local user.

§Arguments
  • identity - The new OkuNet identity.
§Returns

The hash of the new identity file in the local user’s home replica.

Source

pub async fn set_display_name(&self, display_name: String) -> Result<Hash>

Replaces the current display name of the local user.

§Arguments
  • display_name - The new display name.
§Returns
§The hash of the new identity file in the local user’s home replica.
Source

pub async fn toggle_follow(&self, author_id: AuthorId) -> Result<Hash>

Follow or unfollow a user.

§Arguments
  • author_id - The user to follow or unfollow’s content authorship ID.
§Returns

The hash of the new identity file in the local user’s home replica.

Source

pub async fn toggle_block(&self, author_id: AuthorId) -> Result<Hash>

Block or unblock a user.

§Arguments
  • author_id - The user to block or unblock’s content authorship ID.
§Returns

The hash of the new identity file in the local user’s home replica.

Source

pub async fn is_followed(&self, author_id: &AuthorId) -> bool

Check if a user is followed.

§Arguments
  • author_id - The user’s content authorship ID.
§Returns

Whether or not the user is followed.

Source

pub async fn is_blocked(&self, author_id: &AuthorId) -> bool

Check if a user is blocked.

§Arguments
  • author_id - The user’s content authorship ID.
§Returns

Whether or not the user is blocked.

Source

pub async fn is_me(&self, author_id: &AuthorId) -> bool

Check whether or not an author ID is the local user’s.

§Arguments
  • author_id - A user’s content authorship ID.
§Returns

Whether or not the user’s authorship ID is the local user’s.

Source

pub async fn user(&self) -> Result<OkuUser>

Retrieves an OkuUser representing the local user.

§Returns

An OkuUser representing the current user, as if it were retrieved from another Oku user’s database.

Source

pub async fn post_from_entry(&self, entry: &Entry) -> Result<OkuPost>

Attempts to retrieve an OkuNet post from a file entry.

§Arguments
  • entry - The file entry to parse.
§Returns

An OkuNet post, if the entry represents one.

Source

pub async fn posts_from_user(&self, user: &OkuUser) -> Result<Vec<OkuPost>>

Retrieves OkuNet posts from the file entries in an OkuUser.

§Arguments
  • user - The OkuNet user record containing the file entries.
§Returns

A list of OkuNet posts contained within the user record.

Source

pub async fn create_or_modify_post( &self, path: Option<PathBuf>, url: Url, title: String, body: String, tags: HashSet<String>, ) -> Result<Hash>

Create or modify an OkuNet post in the user’s home replica.

§Arguments
  • path - The path to create, or modify, the post at; a suggested path is generated if none is provided.

  • url - The URL the post is regarding.

  • title - The title of the post.

  • body - The body of the post.

  • tags - A list of tags associated with the post.

§Returns

A hash of the post’s content.

Source

pub async fn delete_post(&self, path: PathBuf) -> Result<usize>

Delete an OkuNet post in the user’s home replica.

§Arguments
  • path - A path to a post in the user’s home replica.
§Returns

The number of entries deleted in the replica, which should be 1 if the file was successfully deleted.

Source

pub async fn refresh_users(&self) -> Result<()>

Refreshes any user data last retrieved longer than REPUBLISH_DELAY ago according to the system time; the users one is following, and the users they’re following, are recorded locally. Blocked users are not recorded.

Source

pub async fn fetch_users(&self) -> Result<()>

Retrieves user data regardless of when last retrieved; the users one is following, and the users they’re following, are recorded locally. Blocked users are not recorded.

Source

pub async fn resolve_author_id(&self, author_id: AuthorId) -> Result<DocTicket>

Use the mainline DHT to obtain a ticket for the home replica of the user with the given content authorship ID.

§Arguments
  • author_id - A content authorship ID.
§Returns

A ticket for the home replica of the user with the given content authorship ID.

Source

pub async fn fetch_post( &self, author_id: AuthorId, path: PathBuf, ) -> Result<OkuPost>

Join a swarm to fetch the latest version of an OkuNet post.

§Arguments
  • author_id - The authorship ID of the post’s author.

  • path - The path to the post in the author’s home replica.

§Returns

The requested OkuNet post.

Source

pub async fn get_or_fetch_post( &self, author_id: AuthorId, path: PathBuf, ) -> Result<OkuPost>

Retrieves an OkuNet post from the database, or from the mainline DHT if not found locally.

§Arguments
  • author_id - The authorship ID of the post’s author.

  • path - The path to the post in the author’s home replica.

§Returns

The requested OkuNet post.

Source

pub async fn fetch_profile(&self, ticket: &DocTicket) -> Result<OkuIdentity>

Join a swarm to fetch the latest version of a home replica and obtain the OkuNet identity within it.

§Arguments
  • author_id - A content authorship ID.
§Returns

The OkuNet identity within the home replica of the user with the given content authorship ID.

Source

pub async fn fetch_posts(&self, ticket: &DocTicket) -> Result<Vec<OkuPost>>

Join a swarm to fetch the latest version of a home replica and obtain the OkuNet posts within it.

§Arguments
  • author_id - A content authorship ID.
§Returns

The OkuNet posts within the home replica of the user with the given content authorship ID.

Source

pub async fn get_or_fetch_user(&self, author_id: AuthorId) -> Result<OkuUser>

Obtain an OkuNet user’s content, identified by their content authorship ID.

If last retrieved longer than REPUBLISH_DELAY ago according to the system time, a known user’s content will be re-fetched.

§Arguments
  • author_id - A content authorship ID.
§Returns

An OkuNet user’s content.

Source

pub async fn fetch_user(&self, author_id: AuthorId) -> Result<OkuUser>

Fetch the latest version of an OkuNet user’s content, identified by their content authorship ID.

§Arguments
  • author_id - A content authorship ID.
§Returns

The latest version of an OkuNet user’s content.

Source§

impl OkuFs

Source

pub async fn create_replica(&self) -> Result<NamespaceId>

Creates a new replica in the file system.

§Returns

The ID of the new replica, being its public key.

Source

pub async fn delete_replica(&self, namespace_id: NamespaceId) -> Result<()>

Deletes a replica from the file system.

§Arguments
  • namespace_id - The ID of the replica to delete.
Source

pub async fn list_replicas(&self) -> Result<Vec<(NamespaceId, CapabilityKind)>>

Lists all replicas in the file system.

§Returns

A list of all replicas in the file system.

Source

pub async fn get_replica_capability( &self, namespace_id: NamespaceId, ) -> Result<CapabilityKind>

Retrieves the permissions for a local replica.

§Arguments
  • namespace_id - The ID of the replica.
§Returns

If either the replica can be read from & written to, or if it can only be read from.

Source

pub async fn fetch_replica_by_id( &self, namespace_id: NamespaceId, path: Option<PathBuf>, ) -> Result<()>

Join a swarm to fetch the latest version of a replica and save it to the local machine.

§Arguments
  • namespace_id - The ID of the replica to fetch.

  • path - An optional path of requested files within the replica.

Source

pub async fn fetch_replica_by_ticket( &self, ticket: &DocTicket, path: Option<PathBuf>, ) -> Result<Doc>

Join a swarm to fetch the latest version of a replica and save it to the local machine.

§Arguments
  • ticket - A ticket for the replica to fetch.

  • path - An optional path of requested files within the replica.

§Returns

A handle to the replica.

Source

pub async fn sync_replica(&self, namespace_id: NamespaceId) -> Result<()>

Join a swarm to fetch the latest version of a replica and save it to the local machine.

If a version of the replica already exists locally, only the last-fetched paths will be fetched.

§Arguments
  • namespace_id - The ID of the replica to fetch.
Source

pub async fn resolve_namespace_id( &self, namespace_id: NamespaceId, ) -> Result<DocTicket>

Use the mainline DHT to obtain a ticket for the replica with the given ID.

§Arguments
  • namespace_id - The ID of the replica to fetch.
§Returns

A ticket for the replica with the given ID.

Source

pub async fn create_document_ticket( &self, namespace_id: NamespaceId, share_mode: ShareMode, ) -> Result<DocTicket>

Create a sharing ticket for a given replica.

§Arguments
  • namespace_id - The ID of the replica to share.

  • share_mode - Whether the replica should be shared as read-only, or if read & write permissions are to be shared.

§Returns

A ticket to retrieve the given replica with the requested permissions.

Trait Implementations§

Source§

impl Clone for OkuFs

Source§

fn clone(&self) -> OkuFs

Returns a copy 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 Debug for OkuFs

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for OkuFs

§

impl !RefUnwindSafe for OkuFs

§

impl Send for OkuFs

§

impl Sync for OkuFs

§

impl Unpin for OkuFs

§

impl !UnwindSafe for OkuFs

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

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

§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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> Instrument for T

Source§

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

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

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

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either [OwoColorize::fg] or a color-specific method, such as [OwoColorize::green], Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either [OwoColorize::bg] or a color-specific method, such as [OwoColorize::on_yellow], Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

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

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

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

Source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
§

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
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T