Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction { /* private fields */ }
Expand description

A set of staged objects and queued writes to one repository.

Repo::transaction and Repo::transaction_with_lock begin a transaction. The transaction holds the repository lock and its own staging directory until it ends. commit publishes the staged objects and writes the queued refs and detached metadata. abort discards them.

If a transaction drops without commit or abort, it removes its staging directory with each staged object and releases the lock. So an abandoned transaction leaves nothing behind.

§Concurrency

One process can hold many transactions at once, each with its own staging directory. The repository lock coordinates them. It also excludes other processes and the ostree command, as LockKind states.

&Transaction is Send + Sync, so concurrent writers can stage objects through one shared reference. A mutex guards the state that the writers share: the set of staged objects for the dedup, the free-space budget, and the archive size records.

§Staging directory

A transaction stages its objects in tmp/staging-<boot-id>-XXXXXX. It creates the directory when it begins and removes it when it ends. While the transaction lives, it holds an exclusive record lock on the sibling file staging-<boot-id>-XXXXXX-lock.

The boot id separates the directories of the current boot from the directories of earlier boots. The owner of a directory of the current boot can still be alive. The owner of a directory of an earlier boot is gone.

When a transaction begins, it removes these stale entries at the top level of tmp/:

  • A staging directory whose lock it can take, because no live holder has the lock.
  • A staging directory with no lock file, if the directory is older than tmp-expiry-secs. The age test is necessary because another process can be in the middle of the creation of the directory.
  • Each other entry whose mtime is older than tmp-expiry-secs, as the ostree command does. A directory goes as a whole tree, by its own mtime. A symlink goes as the link itself.

It never touches tmp/cache, and it never removes a staging directory that this process owns. A staging lock file has no age test, because a transaction can live longer than tmp-expiry-secs and still hold the lock.

A ref write, a detached-metadata write, and a tombstone write create a temp entry at the top level of tmp/ and rename it over the target. The entry of a ref write is named .ostrya-ref-<pid>-<n>-XXXXXX. The entry of the other two writes is named .ostrya-meta-<pid>-<n>-XXXXXX. The age test applies to such an entry.

If tmp-expiry-secs is very small or negative, a transaction that begins can remove the entry before its rename. The write then fails with ENOENT, and the ref or the object stays unchanged.

§Examples

Commit the directory /srv/rootfs and point a ref at the new commit:

use std::os::fd::AsFd;
use std::path::Path;

use ostrya::{CommitOptions, MutableTree, Ref, Repo};

let repo = Repo::open(Path::new("/srv/repo")).await?;
let txn = repo.transaction().await?;

let parent = std::fs::File::open("/srv")?;
let mut mtree = MutableTree::new();
txn.write_dfd_to_mtree(parent.as_fd(), Path::new("rootfs"), &mut mtree, None)
    .await?;
let root = txn.write_mtree(&mut mtree).await?;

let opts = CommitOptions {
    subject: Some("Build 1".into()),
    ..CommitOptions::default()
};
let commit = txn.write_commit(opts, &root).await?;
txn.set_ref(&Ref::local("exampleos/stable"), Some(&commit));
let stats = txn.commit().await?;
println!("{} content objects written", stats.content_written);

Implementations§

Source§

impl Transaction

Methods that set the options of a transaction, read its staged trees, queue detached metadata, and end it.

Source

pub fn set_fsync(&mut self, enabled: bool)

Overrides the [core] fsync value for this transaction alone.

The value applies to the whole transaction: the per-object writes, the publication step, the detached-metadata writes, and the ref writes. It changes the durability of the writes and no byte that the repository stores. commit states the sync sequence.

Source

pub fn set_per_object_fsync(&mut self, enabled: bool)

Overrides the [core] per-object-fsync value for this transaction alone.

If the value is true, the transaction syncs the file of each content object when it stages the object, before publication. It never syncs a metadata object on its own. It does not sync an object imported by hardlink.

The value has no effect while fsync is off, from the config or from set_fsync. It changes the durability of the writes and no byte that the repository stores. commit states the sync sequence.

Source

pub fn set_generate_sizes(&mut self, enabled: bool)

Sets if each commit of this transaction carries the ostree.sizes key.

A file system ingest under GENERATE_SIZES turns the key on. This call serves an ingest that runs no commit modifier, for example the tar import. The value holds for the whole transaction and overrides the flag of each ingest, so false turns the key off again.

Outside archive mode the call has no effect, because no other mode writes the key.

Source

pub fn begin_tree_source(&self)

Starts a new tree source for the ostree.sizes key.

The ostree command limits the key to the objects that the last tree source added, plus the directory objects that the tree serialization writes. So a content object from an earlier source leaves the key, and a directory object stays.

A caller that builds a commit from several sources calls this method before each source. Then the key that ostrya writes is the key that the ostree command writes. If a caller never calls this method, the key covers each object that the commit reaches.

The --base layer of a commit goes in before the first call, so it adds nothing to the key. The ostree command records the same key.

Source

pub fn is_commit_staged(&self, commit: &Checksum) -> bool

Returns true if the commit object commit is staged in this transaction.

write_commit stages a new commit. A commit that the repository holds before the write, complete or partial, is not staged. A caller that attaches the image of a new commit alone with attach_composefs_image checks the commit with this call. The call reads the staged set of this transaction, so another writer under the shared lock does not change its result. A Repo::has_object check after the write reads the object store, and another transaction can publish the same commit before that check.

Source

pub async fn read_dir(&self, tree: &RepoTree) -> Result<Vec<TreeEntry>>

Lists one directory of a tree that this transaction staged.

The call reads the objects that this transaction staged first, and then objects/. A caller can use it to derive commit metadata from a tree before the transaction commit.

RepoTree::read_dir reads objects/ alone, so it sees a tree only after the transaction commit. The order of the entries is the same in both calls: files first, then subdirectories, each group sorted by name.

Before the transaction commit, RepoTree::read_dir on a TreeEntry::Dir of a staged tree fails with Error::ObjectNotFound. This method reads such an entry.

§Errors
Source

pub fn set_commit_detached_metadata(&self, checksum: &Checksum, meta: Value)

Queues the detached metadata of a commit that this transaction writes.

meta is an a{sv} dict. It replaces the detached metadata that the repository stores for checksum. The write happens at commit, after the staged objects publish and before the queued ref writes. So the commit and its detached metadata are durable before a ref names them.

If the call runs twice for one checksum, the last dict stays. The call also drops the signatures that sign_commit queued before it, and the build sources that add_detached_related queued before it.

The call does not check meta, and it cannot fail. commit checks each ostrya.related entry of the queued dict, as Repo::write_commit_detached_metadata does. If an entry is defective, commit fails with Error::InvalidRelated and publishes nothing.

Queues the build source name with the checksum source for the detached metadata of the commit commit.

The write at commit adds the entry to the first ostrya.related entry of the detached metadata, as Repo::add_detached_related does: it removes each element with the name name, adds the new element, and keeps the elements sorted by name in byte order. The write adds the entries of all calls for one commit in one step. The result is the same as one add for each call, in call order, after the dict that set_commit_detached_metadata queued, or else after the stored dict. The signatures that sign_commit queues come after the adds.

The call does not check that the transaction or the repository holds commit or source, and it writes nothing to the file system.

If the stored value of the first ostrya.related entry is defective, the write at commit fails with Error::InvalidRelated. The commit fails after it publishes the staged objects. It then writes no ref, and the .commitmeta file of commit stays as it was. The detached-metadata edits of other commits that the queue holds before this one stay written.

§Errors

Error::InvalidRelated with commit and RelatedField::BuildSources if name is empty. The call then queues nothing.

Source

pub async fn sign_commit( &self, checksum: &Checksum, signer: &dyn Signer, ) -> Result<()>

Signs a commit that this transaction wrote and queues the signature.

The signature goes into the detached metadata of the commit. The payload is the canonical bytes of the commit object. The call reads them from the staging directory if the object is staged, and from objects/ if the repository holds the object already.

The signature appends to the aay array of the engine, in the first of these dicts that exists:

  1. The dict that set_commit_detached_metadata queued.
  2. The dict that the repository stores at the time of the write.
  3. An empty dict.

The call writes nothing to the file system. The signing step comes before the object publication and the ref writes. So a signer failure fails the transaction before it publishes an object or moves a ref.

§Concurrent signers

The queue step takes one lock and holds no await. The call makes the signature here, before it takes a lock of the commit.

The write at commit reads, merges, and replaces the file under the update lock. So each signature that tasks or processes make for one commit reaches the file: from one transaction, from concurrent transactions, and from Repo::sign_commit. The ostree command can lose a signature in that case.

§Errors
Source

pub async fn commit(self) -> Result<TransactionStats>

Publishes the staged objects into objects/ and writes the queued refs.

§Sequence
  1. The call checks each queued refspec. If a refspec is malformed, the call fails before it publishes an object, and it writes nothing. The call then checks each ostrya.related entry of each dict that set_commit_detached_metadata queued, as Repo::write_commit_detached_metadata does. On a refusal the call publishes no object and writes nothing.
  2. If [ex-ostrya] generate-composefs is true, the call builds the composefs image of each commit that the writer recorded as complete, as # Composefs images states. If a build fails, the call publishes no object and writes nothing.
  3. The call renames each staged object into objects/<xx>/, and then each staged composefs image into extensions/ostrya/composefs/<xx>/. So an image is in place only after each object of the transaction. The rename of an image replaces a stored image of the same commit.
  4. The call writes the queued detached-metadata edits.
  5. The call writes the queued refs. Each ref write is atomic: a temp file, then a rename. The set of ref writes is not atomic as a whole.
  6. The call removes the staging directory and releases the repository lock.

Steps 4 and 5 run in one trip to the blocking pool.

§Composefs images

Each writer of a complete commit records the commit for the build of step 2: write_commit, write_commit_checked, a pull from a remote, a local pull, a receive with ref updates, and Repo::apply_static_delta. The commit writes and Repo::apply_static_delta record a commit only if they stage its object, so a commit that the repository holds already, complete or partial, gets no image from them. A pull records each commit that it completes: the targets, the parents within the depth, the dependencies, and each held partial commit. A partial commit is not recorded. write_metadata records no commit. Repo::commit_add_composefs_metadata and the server commit of a receive build the image of their commit themselves, and stage it if the transaction stages the commit. So step 2 does not build it again.

The build reads each recorded commit, staged first. It skips a commit that the transaction did not stage and that has no .commitpartial marker, so a commit that the repository holds complete before the transaction gets no image. It also skips a commit with no ostree.composefs.digest.v0 key and a commit whose image is staged. For each other commit, it makes the steps of write_composefs_image. The build reads the fs-verity digest of a sealed object from the kernel. It reads and hashes each other object one time, and uses that digest for each commit and each path that names the object.

§Durability

One fsync policy applies to all steps: the value from set_fsync, or else [core] fsync of the repository config. With fsync on, the call syncs as follows:

  • Before the renames of step 3, it runs syncfs on the repository.
  • After the renames of the objects, it runs fsync on each fanout directory that got an object, and on objects/.
  • After the renames of the images, it runs fsync on each extensions/ostrya/composefs/<xx>/ directory that got an image, and on extensions/ostrya/composefs/. It syncs each directory that the call creates into its parent.
  • Before the rename of each ref, it runs fdatasync on the temp file.
  • After the last ref rename, it runs fsync once on each directory that gained or lost a ref name, deepest first.

With this sequence, a commit and its .commitmeta are durable before a ref names them. Each ref is durable when the call returns. With fsync off, no step syncs.

§Locks

The transaction holds the repository lock from its begin to the end of this call, in the LockKind of its begin. Steps 2 and 3 run with no update lock.

If the transaction writes a ref, a ref removal included, or detached metadata, the call takes the update lock for steps 4 and 5. The update lock excludes the other writers of refs and detached metadata, as UpdateGuard states. The wait is for the update lock alone, because the transaction holds the repository lock already. A transaction that writes neither does not take the update lock.

§Cancellation

The update lock, the repository lock, and the staging directory move into the blocking closure of steps 4 and 5. The closure releases them when its writes end. If a caller drops the returned future, the writes complete, and the locks and the staged files stay until the writes end.

§Errors
  • Error::InvalidRefspec if a queued refspec is malformed, or if the collection id of a queued collection ref does not pass is_collection_id or is longer than 255 bytes. The call publishes no object and writes no ref.
  • Error::InvalidRelated if an ostrya.related entry of a queued detached-metadata dict is not a variant of type a(say), or if one of its elements has an empty name or a checksum that is not 32 bytes. The call publishes no object and writes nothing.
  • Error::InvalidRelated if a build source that add_detached_related queued meets a defective stored ostrya.related value. The published objects stay, and the call writes no ref.
  • Under [ex-ostrya] generate-composefs, the errors of write_composefs_image for a recorded commit. Among them, Error::InvalidFormat if the value of the digest key of the commit is malformed, and Error::ComposefsDigestMismatch if the image of its tree does not have the digest that the key records. The call publishes no object and writes nothing.
  • The errors of RepoConfig::generate_composefs if a writer recorded a commit.
  • Error::InvalidFormat if a staged composefs image meets a component of extensions/ostrya/composefs/<xx>/ that is a symlink or no directory. The objects and the images that the call renamed before stay, and the call writes no detached metadata and no ref.
  • Error::LockTimeout if the wait for the update lock passes [core] lock-timeout-secs. The published objects stay, and the call writes no detached metadata and no ref.
  • Error::Core if [core] fsync, [core] per-object-fsync, or [core] lock-timeout-secs has a value that does not parse.
  • Error::Core if the stored detached metadata of a commit does not parse.
  • Error::InvalidFormat if [core] lock-timeout-secs is less than -1, or if a signature entry of the stored detached metadata is not an array.
  • Error::Io if a rename, a sync, or a write of a ref or of the detached metadata fails.
Source

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

Discards the transaction and its staged objects, and releases the lock.

The call first waits for each blocking job of the transaction that a dropped future left before the job ended.

§Errors

The call does not fail. It always returns Ok(()).

Source§

impl Transaction

Methods that read the kernel version of a staged tree.

Source

pub async fn kernel_version( &self, root: &RepoTree, ) -> Result<Result<String, BootableRefusal>>

Returns the kernel version of a tree that this transaction staged.

The version is the value of ostree.linux. The search reads each dirtree with read_dir, so it sees the objects that this transaction staged and the objects in objects/. A caller can derive the metadata of a commit before the transaction commit.

The search rules are the same as in RepoTree::kernel_version. The inner Result holds the version or a BootableRefusal. A refusal is an outcome of the search. The outer Result holds the errors of the object reads.

§Errors
Source§

impl Transaction

Methods that write a commit object.

Source

pub async fn write_commit( &self, opts: CommitOptions, root: &RepoTree, ) -> Result<Checksum>

Stages a commit object over the tree root and returns its checksum.

The call stages the commit in the same way as other metadata objects. The root dirtree and the root dirmeta come from root. The other fields come from opts.

The metadata dict is opts.metadata, or an empty dict if it is None. The call adds no key of its own except ostree.sizes. The binding keys ostree.ref-binding and ostree.collection-binding are normal metadata entries that the caller supplies.

§ostree.sizes

The commit gets the ostree.sizes key if the transaction generates sizes and the repository is in archive mode. A file system ingest under GENERATE_SIZES turns size generation on. set_generate_sizes sets it for the whole transaction.

The key is the last metadata entry, as in a commit of the ostree command. Its records cover the objects that the committed root reaches, and no other objects:

  • the root dirmeta
  • each dirtree
  • each subdirectory dirmeta
  • each file entry

The commit object is not in the list, because the walk starts below it. If a transaction stages more than one commit, the key of each commit holds the objects that this commit reaches. If the caller uses begin_tree_source, the key holds the objects of the last tree source and the directory objects.

The call walks the committed tree at commit time. An object that the transaction staged uses the size record that the transaction kept. An object that deduplicated against objects/ gets its sizes from its loose object. As in a commit of the ostree command, an incremental commit also lists the objects that existed before.

In each other mode the call writes no key. The bytes of the commit are the same with and without the request.

§Composefs image

If the call stages the commit object, it records the commit as complete. If [ex-ostrya] generate-composefs is true and the commit carries ostree.composefs.digest.v0, commit then builds and stores the composefs image of the commit. A commit that the repository holds already, complete or partial, is not staged, so it gets no image.

§Dependencies

Field 2 of the commit object holds the entries of opts.related, sorted by name in byte order. The call refuses an entry with an empty name and two entries with the same name. It checks nothing else in a name.

Each dependency must be complete: this transaction stages its commit object or the repository holds it, and the repository holds no state/<checksum>.commitpartial marker for it. A dependency that this transaction writes must be staged before the call that names it. A dependency must have no dependency of its own, so a dependency names no dependency. It can have a parent and build sources.

The call checks the dependencies as check_related does, after the timestamp and before it serializes the commit. On a refusal, it writes nothing and the transaction stays open.

A caller that checks the dependencies before it builds the tree calls check_related and then write_commit_checked. Then each dependency is checked one time.

§Errors
  • Error::Unsupported if the repository mode is bare-split-xattrs.
  • Error::InvalidRelated if an entry of opts.related has an empty name, if two entries have the same name, or if a dependency is absent, partial, or has a dependency of its own.
  • Error::Core if the commit tuple of a dependency does not frame, or if its field 2 does not decode.
  • Error::Unsupported if [ex-integrity] fsverity is yes and the fs-verity seal fails.
  • Error::InvalidFormat if opts.timestamp is None and SOURCE_DATE_EPOCH is not a count of seconds.
  • Error::InvalidFormat if the call reads the system clock and the clock is before the Unix epoch.
  • Error::InvalidFormat if the call adds ostree.sizes and opts.metadata is not an array value.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::Core if the commit does not serialize: opts.metadata is not an a{sv} dict, a string holds an interior NUL byte, or the metadata nests too deep.
  • Error::Core if [core] fsync or [core] per-object-fsync in the repository config is malformed.
  • Error::Core if the call adds ostree.sizes and a dirtree that the commit reaches does not parse.
  • Error::ObjectNotFound if the call adds ostree.sizes and an object that the commit reaches is in neither the staging directory nor objects/.
  • The errors of load_file if the call adds ostree.sizes and a file object from objects/ does not load.
  • Error::InsufficientFreeSpace if the commit object needs more space than the free-space budget of the transaction holds.
  • Error::Io if the call adds ostree.sizes and a dirtree that the commit reaches is larger than MAX_METADATA_SIZE.
  • Error::Io if a file system operation fails.
Source

pub async fn write_commit_checked( &self, opts: CommitOptions, related: CheckedRelated<'_>, root: &RepoTree, ) -> Result<Checksum>

Stages a commit object over the tree root with the dependencies related, and returns its checksum.

The call writes the commit as write_commit does. Field 2 of the commit object holds the entries of related, sorted by name in byte order. opts.related must be empty. For the same inputs, the call and write_commit give the same commit.

The call records the commit for the composefs image as write_commit does.

The call does not check the dependencies again. check_related checked them. A process outside the transaction can make a dependency partial or absent after that check: for example, an fsck, which takes no repository lock, or a prune in a repository with [core] locking=false. The call does not refuse such a dependency, and an fsck reports it.

§Errors

The call checks the origin of related, then opts.related, then the repository mode, then the timestamp. On these refusals, it writes nothing and the transaction stays open.

  • Error::InvalidInput if related comes from another transaction.
  • Error::InvalidInput if opts.related is not empty.
  • Error::Unsupported if the repository mode is bare-split-xattrs.
  • Error::Unsupported if [ex-integrity] fsverity is yes and the fs-verity seal fails.
  • Error::InvalidFormat if opts.timestamp is None and SOURCE_DATE_EPOCH is not a count of seconds.
  • Error::InvalidFormat if the call reads the system clock and the clock is before the Unix epoch.
  • Error::InvalidFormat if the call adds ostree.sizes and opts.metadata is not an array value.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::Core if the commit does not serialize: opts.metadata is not an a{sv} dict, a string holds an interior NUL byte, or the metadata nests too deep.
  • Error::Core if [core] fsync or [core] per-object-fsync in the repository config is malformed.
  • Error::Core if the call adds ostree.sizes and a dirtree that the commit reaches does not parse.
  • Error::ObjectNotFound if the call adds ostree.sizes and an object that the commit reaches is in neither the staging directory nor objects/.
  • The errors of load_file if the call adds ostree.sizes and a file object from objects/ does not load.
  • Error::InsufficientFreeSpace if the commit object needs more space than the free-space budget of the transaction holds.
  • Error::Io if the call adds ostree.sizes and a dirtree that the commit reaches is larger than MAX_METADATA_SIZE.
  • Error::Io if a file system operation fails.

Checks the dependencies related of a new commit, as write_commit checks CommitOptions::related.

The call refuses an entry with an empty name and two entries with the same name. Then it checks each dependency in the byte order of the names: the dependency must be complete in the repository or in this transaction, and it must have no dependency of its own. write_commit states the rules and runs the same checks. The call does not change related and writes nothing.

The call reads no tree. A caller can call it before it builds a large tree, so that a refused dependency stops the work before the build.

Returns the checked entries, sorted by name in byte order. write_commit_checked takes them and writes the commit with no second check.

§Errors
  • Error::InvalidRelated with no commit, if an entry of related has an empty name, if two entries have the same name, or if a dependency is absent, partial, or has a dependency of its own.
  • Error::Core if the commit tuple of a dependency does not frame, or if its field 2 does not decode.
  • Error::Io if the commit object of a dependency with no partial marker is larger than MAX_METADATA_SIZE, or if a file system operation fails.
Source§

impl Transaction

Methods that compute the composefs digest of a staged tree and stage the composefs image of a commit.

Source

pub async fn composefs_digest(&self, root: &RepoTree) -> Result<[u8; 32]>

Returns the composefs image digest of a tree that this transaction staged.

The value is the one that ostree.composefs.digest.v0 holds: the fs-verity digest of the image that an export with ComposefsOptions::RECORDED writes for the same tree. Repo::export_composefs describes the image.

The call reads each object that this transaction staged from the staging directory, and each other object from objects/. The digest is available before the transaction commit, so it can go into the metadata of the commit that the tree belongs to. The value depends on the tree alone, so a repository of any mode that holds the tree gives the same digest.

The image goes to std::io::sink, so the digest needs no image-sized buffer.

§Errors
Source

pub async fn build_composefs_image( &self, root: &RepoTree, ) -> Result<StagedComposefsImage<'_>>

Writes the composefs image of a tree to the staging directory of this transaction.

The image is the image that an export with ComposefsOptions::RECORDED writes for the same tree, so StagedComposefsImage::digest is the value of composefs_digest. The call reads the objects of the tree as composefs_digest reads them. A caller that writes a new commit takes the digest for the key ostree.composefs.digest.v0 of the commit, writes the commit, and then gives the image to attach_composefs_image. The tree is then read one time.

The writer computes the fs-verity digest as it writes the image, and it holds no image-sized buffer. The image file has the mode 0644. If [ex-integrity] fsverity is not no, the call seals the file and compares the digest that the kernel reads with the digest of the writer. If the fsync and per-object-fsync values of the transaction are both on, the call syncs the file. Each value comes from set_fsync or set_per_object_fsync if the transaction has an override, and else from [core] fsync or [core] per-object-fsync.

§Errors
Source

pub async fn attach_composefs_image( &self, commit: &Checksum, image: StagedComposefsImage<'_>, ) -> Result<ComposefsImageAdd>

Stages image as the composefs image of commit.

The commit comes from the staged set of this transaction, or else from objects/. The call checks the digest of the image against the key ostree.composefs.digest.v0 of the commit, and refuses a mismatch. It then compares the stored image of the commit with the key, if the repository holds one. The call streams the stored image through the fs-verity hasher.

If the call does not stage the image, it removes the image file.

commit renames a staged image into extensions/ostrya/composefs/<xx>/ after it renames the objects of the transaction into objects/. The rename replaces the stored image in one step. No field of TransactionStats counts the image, and ostree.sizes has no entry for it. The image takes its size from the free-space budget of the transaction.

§Errors
Source

pub async fn write_composefs_image( &self, commit: &Checksum, ) -> Result<ComposefsImageAdd>

Builds and stages the composefs image of commit.

The call runs build_composefs_image over the root of the commit and attach_composefs_image with the result. If the repository holds a valid image of the commit already, the call builds nothing and returns ComposefsImageAdd::AlreadyValid.

The call does not refuse a partial commit. If an object of the tree is absent, the build fails.

§Errors
Source§

impl Transaction

Methods that read a directory on disk into a mutable tree.

Source

pub async fn write_dfd_to_mtree( &self, dfd: BorrowedFd<'_>, path: &Path, mtree: &mut MutableTree, modifier: Option<&mut CommitModifier>, ) -> Result<()>

Walks the directory at path under dfd and adds its tree to mtree.

The metadata of the walk root becomes the dirmeta of mtree. The walk adds each entry below the root to mtree:

  • The payload of a regular file streams into a content object.
  • A symlink and the metadata of each directory become objects.
  • A directory merges with a directory of the same name in mtree.
  • A regular file or a symlink replaces a file of the same name in mtree.

write_mtree writes the dirtree of each directory later. If path is empty or ., the walk root is dfd itself. The walk does not follow a symlink at the last component of path.

§Modifier

Without a modifier, each entry records the ownership, the mode, and the xattrs that it has on disk. A CommitModifier applies its steps to each entry in this order:

  1. The CANONICAL_PERMISSIONS reduction: owner 0:0, no xattrs, and perm & 0o755 on a regular file or a directory. A symlink keeps its mode.
  2. SKIP_XATTRS: the walk reads no xattrs from the disk, and the entry has no xattrs.
  3. The declared ownership (owner_uid and owner_gid).
  4. The filter. It gets the metadata of steps 1 to 3. If it returns FilterResult::Skip for a directory, the walk skips the whole subtree.
  5. The mode callback.
  6. The CANONICAL_PERMISSIONS reduction again, on the mode that the callback returns. The file type stays the type that the walk found. A symlink keeps its mode.
  7. The xattr callback.
  8. The SELinux label callback. The walk drops the security.selinux xattr of the entry, then adds the label that the callback returns. If the callback returns no label, the entry has no label.

Steps 5 to 8 run only for an entry that the filter keeps. The walk root goes through each step except the filter.

If the modifier holds a DevInoCache, the walk looks up each regular file and symlink in it, and never a directory. The walk does not read a source file that the cache knows. Without DEVINO_CANONICAL, a hit takes its metadata from the stored object. For this reason, a user.ostreemeta xattr on a file of a bare-user checkout does not enter the commit.

§Consume

Under CONSUME, the walk removes each source entry after it records the entry. It also removes each entry that the filter skips, with its whole subtree. Then the call removes the walk root.

The test for the walk root is on the bytes of path. If path is exactly ., the call keeps the root. For each other spelling, ./ included, the call tries to remove the root and ignores a failure.

§File system access

The walk reads each directory in one pass on the blocking pool. The pass reads the entry list, the statat of each entry, the xattrs, and the symlink targets. The walk reads the xattrs of a symlink from the link itself. The calls that open and remove entries run on the calling task. The walk holds at most two directory descriptors at a time, at any depth of the source.

§Errors
Source§

impl Transaction

Methods that read a committed tree into a mutable tree.

Source

pub async fn overlay_tree_to_mtree( &self, dirtree: &Checksum, dirmeta: &Checksum, mtree: &mut MutableTree, modifier: Option<&mut CommitModifier>, ) -> Result<()>

Merges the committed tree of dirtree and dirmeta into mtree.

The merge obeys the rules of write_dfd_to_mtree, so a committed tree and a walk of the file system can build one tree under one modifier. dirmeta becomes the dirmeta of mtree. A directory merges with a directory of the same name, and a file replaces a file of the same name.

If modifier is None, the merge records the committed checksums unchanged. It reads only the dirtrees on the paths where mtree already holds a directory. It records each other subdirectory with no read.

If modifier is set, the merge reads each entry and applies the steps of the modifier to its metadata, in the order that write_dfd_to_mtree states. If the result differs from the stored metadata, the merge writes a new object from the stored payload. Otherwise it records the stored checksum. The merge does not use CONSUME, GENERATE_SIZES, DEVINO_CANONICAL, or the devino cache.

The transaction can write ostree.sizes in an archive repository after a call to begin_tree_source. Then each object of the committed tree enters the scope of that key, also an object that the merge does not write.

§Errors
Source§

impl Transaction

Methods that write a mutable tree as dirtree objects.

Source

pub async fn write_mtree(&self, mtree: &mut MutableTree) -> Result<RepoTree>

Writes the changed subtrees of mtree as dirtree objects.

The call stages each new dirtree as an object of GVariant type (a(say)a(sayay)), and returns the root as a RepoTree. The walk is post-order: it writes the children of a directory before the directory. A subtree with no change keeps its committed dirtree checksum, and the call does not serialize or stage it again, as MutableTree states.

Each directory that the call writes must have a dirmeta checksum.

The returned root reads back through this transaction alone, as read_dir states. Before the transaction commit, RepoTree::read_dir on a dirtree that this call staged fails with Error::ObjectNotFound.

§Errors
  • Error::MutableTree if a directory that the call writes has no dirmeta checksum. The message names the path of the directory, with / for the root.
  • Error::Core if an entry name holds a NUL byte, or if [core] fsync or [core] per-object-fsync in the repository config is malformed.
  • Error::Unsupported if the repository mode is bare-split-xattrs, or if [ex-integrity] fsverity is yes and the fs-verity seal fails.
  • Error::InsufficientFreeSpace if a dirtree needs more space than the free-space budget of the transaction holds.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::Io if a file system operation fails.
Source§

impl Transaction

Methods that merge an overlayfs upper directory into a mutable tree.

Source

pub async fn merge_overlay_dfd_to_mtree( &self, dfd: BorrowedFd<'_>, mtree: &mut MutableTree, modifier: Option<&mut CommitModifier>, ) -> Result<()>

Merges the overlayfs upper directory at dfd into mtree.

dfd is the root of the upper directory (the upperdir of the mount). mtree holds the lower layer that the overlay was mounted over. The merge applies the upper directory to mtree as a changeset. The overlay must be unmounted, and the call does not check this.

Each upper entry other than a whiteout becomes an object, and the entry replaces or extends the base tree. The merge is an ostrya extension with no counterpart in the ostree command. It changes no on-disk format, because a deletion acts on the in-memory tree during the walk.

§Overlay rules
  • A whiteout (a character device with device number 0:0) removes its path from the base tree. If the base tree has no entry at the path, the whiteout has no effect.
  • An opaque directory (trusted.overlay.opaque or user.overlay.opaque set to y) clears the base subtree at its name. The merge then reads the upper entries. An opaque root clears the whole base tree.
  • The merge reads both xattr namespaces. A rootless userxattr overlay writes user.*, and an unprivileged reader cannot see trusted.*.
  • A merged (non-opaque) directory takes its dirmeta from the upper inode, because overlayfs copies a directory up with its metadata. The root of the upper directory is a merged directory too.
  • The merge removes each xattr whose name starts with trusted.overlay. or user.overlay. from each file, symlink, and directory that it records, dirmeta included. It keeps every other xattr, also an xattr whose name contains overlay at another position.
  • An entry with an overlay.metacopy or overlay.redirect xattr is an error, because such an entry is not self-contained. The overlay must be mounted with these features off (metacopy=off and redirect_dir=off).
  • An upper entry replaces a base entry of a different type. An upper file or symlink over a base directory removes the directory. An upper directory over a base file or symlink removes the leaf and creates a new directory.

A usrmerge migration changes a directory to a symlink. Overlayfs records this change as a plain leaf with no whiteout and no opaque marker. A non-directory upper entry hides a lower entry of any type.

§Modifier

A CommitModifier applies to each recorded entry the steps that write_dfd_to_mtree lists under its Modifier heading. The root of the upper directory goes through each step except the filter. The merge does not use a DevInoCache or CONSUME.

Whiteouts and opaque markers are merge mechanics, and the modifier does not see them. The other rules for a modifier are these:

  • If the filter returns FilterResult::Skip for an upper entry, the base entry stays as it is. For a directory, the merge skips the whole upper subtree.
  • The merge removes the overlay xattrs before the filter and the callbacks see the xattr set of an entry. The xattr callback can add a removed name again, and the merge does not remove it a second time.
  • Under SKIP_XATTRS, the merge still reads the xattrs of each entry for the overlay rules. The recorded entry has no xattrs.
  • The merge checks for overlay.metacopy and overlay.redirect before the filter, so an entry that the filter skips can cause the error.
§Errors
  • Error::Unsupported if the repository mode is bare-split-xattrs, or if an upper entry is not a directory, a regular file, a symlink, or a whiteout.
  • Error::Unsupported if [ex-integrity] fsverity is yes and the fs-verity seal of an object fails.
  • Error::UnsupportedOverlayFeature if an upper entry has an overlay.metacopy or overlay.redirect xattr in one of the two namespaces.
  • Error::InvalidFormat if an entry name or a symlink target is not valid UTF-8.
  • Error::InvalidFormat if the label callback returns no label and ERROR_ON_UNLABELED is set.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::InvalidFormat if the repository is in bare mode and an xattr name of a symlink is not valid UTF-8.
  • Error::InsufficientFreeSpace if an object needs more space than the free-space budget of the transaction holds.
  • Error::ObjectNotFound if a lazy subdirectory of mtree names a dirtree that the repository does not hold.
  • Error::Core if the dirtree of a lazy subdirectory does not parse, or if the xattr set with a label is not valid.
  • Error::Core if the mode callback returns a file type that the object writer refuses for the entry.
  • Error::Core if a [core] or [archive] value in the repository config is malformed.
  • Error::Core if dfd is not a directory: the dirmeta writer refuses the file type of the root.
  • Error::Io if a file system operation fails.
Source§

impl Transaction

Methods that queue ref writes for the transaction commit.

Source

pub fn set_ref(&self, r: &Ref, checksum: Option<&Checksum>)

Queues a ref write for the transaction commit.

commit writes the ref after it publishes the objects. If checksum is None, the commit removes the ref.

The ref gives the path, as set_ref_immediate states. A collection ref of the [core] collection-id of the repository is at refs/heads/<name>, so the commit writes or removes that file, and it does not touch refs/mirrors/<collection>/.

The call itself does not check the ref. If the ref fails Ref::validate, the commit fails with Error::InvalidRefspec, which holds the text of the ref. The commit then publishes no object and writes no ref.

If a directory of refs/mirrors/ has a name that fails the rule, a ref under it cannot be written or removed through this call. Remove such a ref by hand.

Source§

impl Transaction

Methods that create a staging tree.

Source

pub async fn staging_tree( &self, source: Option<&Commit>, ) -> Result<StagingTree<'_>>

Creates a staging tree over this transaction, empty or from a commit.

With a source commit, the call reads the root dirtree of the commit, and the tree loads each subdirectory when an operation first reaches it. With None, the tree is empty and its root has no dirmeta. write_mtree refuses a root with no dirmeta, so ensure_dir on the path . sets one.

§Errors
Source

pub fn staging_tree_from_mutable_tree( &self, source: MutableTree, ) -> StagingTree<'_>

Creates a staging tree over this transaction from an existing mutable tree.

Source§

impl Transaction

Methods that stage objects.

Source

pub async fn content_writer( &self, expected: Option<&Checksum>, meta: &FileMeta, ) -> Result<ContentWriter<'_>>

Creates a streaming writer for the payload of one regular file.

meta holds the logical uid, gid, mode, and xattrs that the object header records. meta.mode must name a regular file. The call refuses only a mode that names neither a regular file nor a symlink.

If expected is given, finish verifies the computed identity against it. ContentWriter states the identity and the storage form.

§Errors
  • Error::Unsupported if the repository mode is bare-split-xattrs, which ostrya does not write.
  • Error::Core if the file-type bits of meta.mode name neither a regular file nor a symlink.
  • Error::Core if the repository is in archive mode and [archive] zlib-level in the repository config is malformed.
  • Error::Io if the temp file cannot be created or written.
Source

pub async fn write_content( &self, expected: Option<&Checksum>, meta: &FileMeta, reader: impl AsyncRead + Unpin, ) -> Result<Checksum>

Streams the payload of a regular file from reader into a content object.

The call copies reader into a ContentWriter in chunks of 64 KiB, so it never holds the whole payload in memory. meta and expected are as for content_writer. The call returns the checksum of the object.

§Errors
  • Error::Unsupported if the repository mode is bare-split-xattrs, or if [ex-integrity] fsverity is yes and the fs-verity seal fails.
  • Error::ChecksumMismatch if expected is given and differs from the computed checksum.
  • Error::InsufficientFreeSpace if the object needs more space than the free-space budget of the transaction holds.
  • Error::Core if the file-type bits of meta.mode name neither a regular file nor a symlink.
  • Error::Core if a [core] or [archive] value in the repository config is malformed.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::InvalidFormat if the repository is in bare mode and an xattr name in meta is not valid UTF-8.
  • Error::Io if a read from reader fails, or if a file system operation fails.
Source

pub async fn write_regfile_inline( &self, expected: Option<&Checksum>, meta: &FileMeta, data: &[u8], ) -> Result<Checksum>

Writes a regular file whose content the caller holds in memory.

write_content streams a payload from a reader. meta and expected are as for content_writer. The call returns the checksum of the object.

§Errors
  • Error::Unsupported if the repository mode is bare-split-xattrs, or if [ex-integrity] fsverity is yes and the fs-verity seal fails.
  • Error::ChecksumMismatch if expected is given and differs from the computed checksum.
  • Error::InsufficientFreeSpace if the object needs more space than the free-space budget of the transaction holds.
  • Error::Core if the file-type bits of meta.mode name neither a regular file nor a symlink.
  • Error::Core if a [core] or [archive] value in the repository config is malformed.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::InvalidFormat if the repository is in bare mode and an xattr name in meta is not valid UTF-8.
  • Error::Io if a file system operation fails.

Writes a symlink content object and returns its checksum.

A symlink object has no payload, so its identity is the SHA-256 of the framed header alone. The storage form follows the repository mode:

  • In bare and bare-user-only, a symlink.
  • In bare-user and bare-user-shared, a regular file with mode 0644 that holds the target and one NUL. The user.ostreemeta xattr holds the logical metadata.
  • In archive, a framed archive header with no payload.
§Mode

If meta.mode names a symlink, the object records it unchanged, with its permission bits. If meta.mode names a regular file or no file type, the object records S_IFLNK | 0o777. Any other file type fails the write.

§Errors
  • Error::Unsupported if the repository mode is bare-split-xattrs, which ostrya does not write.
  • Error::Unsupported if [ex-integrity] fsverity is yes, the object is stored as a regular file, and the fs-verity seal fails.
  • Error::ChecksumMismatch if expected is given and differs from the computed checksum.
  • Error::InsufficientFreeSpace if the object needs more space than the free-space budget of the transaction holds.
  • Error::Core if meta.mode names a file type other than a symlink or a regular file, or if target holds a NUL byte.
  • Error::Core if [core] fsync or [core] per-object-fsync in the repository config is malformed.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::InvalidFormat if the repository is in bare mode and an xattr name in meta is not valid UTF-8.
  • Error::Io if a file system operation fails.
Source

pub async fn write_dirmeta(&self, meta: &DirMeta) -> Result<Checksum>

Writes a directory-metadata object for meta and returns its checksum.

The object records what the repository mode stores for a directory. bare-user-only discards the ownership and the xattrs, and it reduces the permission bits as for a regular file. A commit into such a repository records this canonical form, and the identity of the dirmeta covers it. Each other mode records meta unchanged.

A commit uses this path for its own directories. A caller that builds a tree uses it too.

A caller can serialize a DirMeta and give the bytes to write_metadata. The object then stores the form that meta states, with the checksum of that form. In a bare-user-only repository, this checksum differs from the checksum that the repository records for the same directory.

A dirmeta from another source, for example a pull or a static delta, keeps the bytes that its checksum names. It goes through write_metadata.

§Errors
  • Error::Unsupported if the repository mode is bare-split-xattrs, or if [ex-integrity] fsverity is yes and the fs-verity seal fails.
  • Error::InsufficientFreeSpace if the object needs more space than the free-space budget of the transaction holds.
  • Error::Core if the file-type bits of meta.mode are not the directory type, or if a [core] value in the repository config is malformed.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::Io if a file system operation fails.
Source

pub async fn write_metadata( &self, ty: ObjectType, expected: Option<&Checksum>, bytes: &[u8], ) -> Result<Checksum>

Writes a metadata object from its serialized bytes in normal form.

The identity is the SHA-256 of bytes. The call returns the checksum of the object.

The call checks no entry of field 2 of a commit. write_commit checks them, and write_commit_checked writes the entries that check_related checked.

The call does not record a commit as complete, because a pull writes partial commits through it. So a commit that it writes gets no composefs image under [ex-ostrya] generate-composefs. A caller that writes a complete commit uses write_commit_checked.

§Errors
  • Error::Unsupported if the repository mode is bare-split-xattrs, or if ty is not a metadata object type.
  • Error::Unsupported if [ex-integrity] fsverity is yes and the fs-verity seal fails.
  • Error::ChecksumMismatch if expected is given and differs from the computed checksum.
  • Error::InsufficientFreeSpace if the object needs more space than the free-space budget of the transaction holds.
  • Error::Core if [core] fsync or [core] per-object-fsync in the repository config is malformed.
  • Error::InvalidFormat if [ex-integrity] fsverity or [ex-integrity] composefs in the repository config is malformed.
  • Error::Io if a file system operation fails.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Conv for T

Source§

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

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

impl<T> FmtForward for T

Source§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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> Pipe for T
where T: ?Sized,

Source§

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

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

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

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

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

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

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

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

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

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

Immutable access to a value. Read more
Source§

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

Mutable access to a value. Read more
Source§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Source§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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

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

Source§

fn vzip(self) -> V

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