pub struct LfsPointer { /* private fields */ }Expand description
Parsed Git LFS pointer with spec-compliant fields
Per the Git LFS specification, pointer files contain:
version- URL of the LFS specoid sha256:- SHA256 hash of the contentsize- Size in bytes- Additional extension fields (preserved for spec compliance)
Fields are private to allow future API evolution without breaking changes.
Implementations§
Source§impl LfsPointer
impl LfsPointer
Sourcepub fn new(version: String, oid: String, size: u64) -> Git2DBResult<Self>
pub fn new(version: String, oid: String, size: u64) -> Git2DBResult<Self>
Create a new LFS pointer with the given fields
This constructor validates the OID format.
Sourcepub fn new_with_hash_method(
version: String,
hash_method: String,
oid: String,
size: u64,
) -> Git2DBResult<Self>
pub fn new_with_hash_method( version: String, hash_method: String, oid: String, size: u64, ) -> Git2DBResult<Self>
Create a new LFS pointer with explicit hash method
Sourcepub fn parse(content: &str) -> Git2DBResult<Self>
pub fn parse(content: &str) -> Git2DBResult<Self>
Sourcepub fn hash_method(&self) -> &str
pub fn hash_method(&self) -> &str
Get the hash method (e.g., “sha256”)
Sourcepub fn extensions(&self) -> &HashMap<String, String>
pub fn extensions(&self) -> &HashMap<String, String>
Get extension fields (spec compliance)
Sourcepub fn to_merkle_hash(&self) -> Git2DBResult<MerkleHash>
👎Deprecated since 0.1.0: unsound: reinterprets LFS SHA-256 as a XET MerkleHash; use the xet-merkle extension via xet_merkle_hash() instead — see #386
pub fn to_merkle_hash(&self) -> Git2DBResult<MerkleHash>
unsound: reinterprets LFS SHA-256 as a XET MerkleHash; use the xet-merkle extension via xet_merkle_hash() instead — see #386
Convert the LFS SHA-256 OID to a XET MerkleHash by hex re-interpretation.
Deprecated and unsound. A XET MerkleHash is BLAKE3 keyed with the global
DATA_KEY over the content-defined chunk DAG, NOT the SHA-256 of the raw
bytes. The two hash families are unrelated; this conversion only succeeds by
coincidence when the upload side also (incorrectly) used the SHA-256 as a
MerkleHash, which real XET never does. Feeding this into smudge_from_hash
therefore cannot resolve real XET content.
New code must populate the xet-merkle extension at promote time and read it
back via LfsPointer::xet_merkle_hash. The smudge path no longer calls this.
Kept temporarily for back-compat callers; emits a tracing::warn! so misuse is
observable in logs. See issue #386.
Sourcepub fn xet_merkle_hex(&self) -> Option<&str>
pub fn xet_merkle_hex(&self) -> Option<&str>
Get the xet-merkle extension value (64-char hex MerkleHash), if present.
Returns None for vanilla LFS pointers that carry no XET metadata. Presence of
this field indicates the pointer is self-describing for Hub-free XET smudge.
Sourcepub fn xet_shard(&self) -> Option<&str>
pub fn xet_shard(&self) -> Option<&str>
Get the xet-shard extension value (opaque locality hint), if present.
Sourcepub fn xet_merkle_hash(&self) -> Git2DBResult<MerkleHash>
pub fn xet_merkle_hash(&self) -> Git2DBResult<MerkleHash>
Resolve the XET MerkleHash for this pointer from the xet-merkle extension.
This is the correct, Hub-free derivation: the hash is read verbatim from the
pointer rather than mis-converted from the LFS SHA-256 OID. Returns a
LfsErrorKind::MissingXetMerkle error if the extension is absent, so callers
cannot silently fall through to the unsound legacy path.
Sourcepub fn set_xet_extensions(&mut self, merkle: &MerkleHash, shard: Option<&str>)
pub fn set_xet_extensions(&mut self, merkle: &MerkleHash, shard: Option<&str>)
Set the xet-merkle and (optionally) xet-shard extensions in place.
Intended for promote-time code that has just computed the real XET MerkleHash
for the blob’s content-defined chunk DAG and wants to record it on the pointer
so downstream smudge is Hub-free and self-describing. Overwrites any prior
value for these keys; other extensions are preserved.
Trait Implementations§
Source§impl Clone for LfsPointer
impl Clone for LfsPointer
Source§fn clone(&self) -> LfsPointer
fn clone(&self) -> LfsPointer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LfsPointer
impl Debug for LfsPointer
Auto Trait Implementations§
impl Freeze for LfsPointer
impl RefUnwindSafe for LfsPointer
impl Send for LfsPointer
impl Sync for LfsPointer
impl Unpin for LfsPointer
impl UnsafeUnpin for LfsPointer
impl UnwindSafe for LfsPointer
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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