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
impl AssetRef
pub fn select(conn: &Connection) -> AssetRefSelect<'_>
pub fn all(conn: &Connection) -> Result<Vec<Self>, ModelSelectError>
Source§impl AssetRef
impl AssetRef
Sourcepub fn materialized_compression_type(&self) -> CompressionType
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.
Sourcepub fn versioned_store_path(
&self,
workspace: &Workspace,
) -> Result<PathBuf, FileAdditionError>
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.
Sourcepub fn reader(
&self,
workspace: &Workspace,
) -> Result<BufReader<StdReader>, FileAdditionError>
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.
Sourcepub fn id_hash(
file_addition: &FileAddition,
role: &AssetRole,
logical_path: Option<&str>,
name: Option<&str>,
upstream_asset_ref_id: Option<&HashId>,
) -> HashId
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.
Sourcepub 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
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.
pub fn create(conn: &GraphConnection, asset_ref: &AssetRef) -> Result<()>
Sourcepub fn get_derived_assets(
conn: &GraphConnection,
upstream_asset_ref_id: &HashId,
history_ref: Option<&str>,
) -> Vec<Self>
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.
Sourcepub fn get_assets_by_commit(
conn: &GraphConnection,
from_hash: Option<&DoltHashId>,
to_hash: Option<&DoltHashId>,
view: AssetView,
) -> Result<IndexMap<DoltHashId, Vec<Self>>, QueryError>
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.
Sourcepub fn get_cumulative_assets_at(
conn: &GraphConnection,
from_hash: Option<&DoltHashId>,
to_hash: Option<&DoltHashId>,
) -> Result<Vec<Self>, QueryError>
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.
Sourcepub fn get_materialized_assets_at(
conn: &GraphConnection,
from_hash: Option<&DoltHashId>,
to_hash: Option<&DoltHashId>,
) -> Result<Vec<Self>, QueryError>
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§
impl Eq for AssetRef
impl StructuralPartialEq for AssetRef
Auto Trait Implementations§
impl Freeze for AssetRef
impl RefUnwindSafe for AssetRef
impl Send for AssetRef
impl Sync for AssetRef
impl Unpin for AssetRef
impl UnsafeUnpin for AssetRef
impl UnwindSafe for AssetRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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