Skip to main content

AssetRef

Struct AssetRef 

Source
pub struct AssetRef {
    pub id: HashId,
    pub uri: String,
    pub file_type: String,
    pub checksum: Option<Sha256Hash>,
    pub size: Option<i64>,
    pub role: AssetRole,
    pub logical_path: Option<String>,
    pub name: Option<String>,
    pub created_on: i64,
    pub upstream_asset_ref_id: Option<HashId>,
    pub materialized_checksum: Option<Sha256Hash>,
}
Expand description

An immutable reference to an asset recorded in repository history.

Several references can have the same logical path because Gen retains every committed version. We have two ways to query for assets – cumulative and materialized. The cumulative query returns an array of every known version of the asset, including older versions whose local path has been updated (for example a generic ./input.fa the user keeps updating for operations).

The materialized query returns the latest asset for a given logical path up to a provided ref. For example if a user imports a genome with a generically named reference.fa and does it again, the materialized query would return the last one.

Use Self::get_cumulative_assets_at when that provenance is needed and Self::get_materialized_assets_at when constructing the one-file-per-path workspace view.

Fields§

§id: HashId§uri: String§file_type: String§checksum: Option<Sha256Hash>§size: Option<i64>§role: AssetRole§logical_path: Option<String>§name: Option<String>§created_on: i64§upstream_asset_ref_id: Option<HashId>

The source asset this asset indexes or otherwise works off.

§materialized_checksum: Option<Sha256Hash>

SHA-256 of the bytes written to the working tree after archive decoding.

This is the checksum of the file that ends up in/is in the workspace directory, not in .assets. If it is None it means its the same as the Asset’s checksum. For some cases, we compress the file when stored in .assets so the asset checksum differs from the materialized checksum.

Implementations§

Source§

impl AssetRef

Source

pub fn select(conn: &Connection) -> AssetRefSelect<'_>

Source

pub fn all(conn: &Connection) -> Result<Vec<Self>, ModelSelectError>

Source§

impl AssetRef

Source

pub fn materialized_compression_type(&self) -> CompressionType

Infers the compression of bytes materialized at this asset’s logical path.

A materialized checksum marks transformed workspace bytes as plain; missing or empty paths also default to plain. This reads only metadata and does not verify the asset bytes.

Source

pub fn versioned_store_path( &self, workspace: &Workspace, ) -> Result<PathBuf, FileAdditionError>

Return the versioned store path for an asset.

Logical paths describe the materialized workspace view and can point at a newer version. Sequence readers use this path so they cannot follow repository metadata outside the repository or silently switch to another asset version.

Source

pub fn reader( &self, workspace: &Workspace, ) -> Result<BufReader<StdReader>, FileAdditionError>

Opens the asset identified by this reference.

Local references resolve through the repository’s content-addressed asset store. Remote references retain their URI and are opened lazily through the configured storage backend.

Source

pub fn id_hash( file_addition: &FileAddition, role: &AssetRole, logical_path: Option<&str>, name: Option<&str>, upstream_asset_ref_id: Option<&HashId>, ) -> HashId

Hashes the normalized asset identity, including both archived and materialized checksums.

Source

pub fn from_file_addition( file_addition: &FileAddition, role: AssetRole, logical_path: Option<&str>, name: Option<&str>, upstream_asset_ref_id: Option<&HashId>, created_on: i64, ) -> Self

Creates an asset reference from a prepared file addition and its provenance metadata.

Source

pub fn create(conn: &GraphConnection, asset_ref: &AssetRef) -> Result<()>

Source

pub fn get_derived_assets( conn: &GraphConnection, upstream_asset_ref_id: &HashId, history_ref: Option<&str>, ) -> Vec<Self>

Returns every asset derived from a given asset.

The relationship is format-independent so sequence, annotation, alignment, and other assets can discover any number of associated indices. There is no grouping mechanism, so all downstream assets will be returned and the caller needs to identify which ones go together.

Source

pub fn get_assets_by_commit( conn: &GraphConnection, from_hash: Option<&DoltHashId>, to_hash: Option<&DoltHashId>, view: AssetView, ) -> Result<IndexMap<DoltHashId, Vec<Self>>, QueryError>

Returns assets grouped by commit.

Commits are in history order with commits without assets having an empty vector.

Source

pub fn get_cumulative_assets_at( conn: &GraphConnection, from_hash: Option<&DoltHashId>, to_hash: Option<&DoltHashId>, ) -> Result<Vec<Self>, QueryError>

Returns every local asset reference present in an inclusive commit range.

This cumulative view retains superseded or subsequently deleted references. Synchronization code needs those versions to recognize previously managed file contents, distinguish an intended update from a user edit, and report conflicts correctly. Omitting to_hash uses HEAD; omitting from_hash walks through the root commit, so omitting both bounds returns the complete history reachable from HEAD.

Source

pub fn get_materialized_assets_at( conn: &GraphConnection, from_hash: Option<&DoltHashId>, to_hash: Option<&DoltHashId>, ) -> Result<Vec<Self>, QueryError>

Returns the one-file-per-logical-path workspace view for an inclusive commit range.

When multiple committed assets share a logical path, the asset introduced by the nearest first-parent commit to the upper bound represents that path. This collapsed view is for deciding which files should be materialized, not for history-aware conflict detection. Omitting to_hash uses HEAD; omitting from_hash walks through the root commit, so omitting both bounds uses the complete history reachable from HEAD.

Trait Implementations§

Source§

impl Clone for AssetRef

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AssetRef

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for AssetRef

Source§

impl PartialEq for AssetRef

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AssetRef

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

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

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

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

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

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = !

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