Skip to main content

Pointer

Struct Pointer 

Source
pub struct Pointer {
    pub oid: Oid,
    pub size: u64,
    pub extensions: Vec<Extension>,
    pub canonical: bool,
}
Expand description

A parsed git-lfs pointer.

A pointer with size == 0 is an empty pointer: it represents an empty file and serializes to the empty byte string. The oid field of an empty pointer is conventionally Oid::EMPTY (SHA-256 of zero bytes).

Fields§

§oid: Oid§size: u64§extensions: Vec<Extension>

Sorted by priority ascending. May be empty.

§canonical: bool

true if this was decoded from input that exactly matched the canonical encoding, or if it was constructed programmatically. Re-encoding a non-canonical parse produces canonical bytes.

Implementations§

Source§

impl Pointer

Source

pub fn new(oid: Oid, size: u64) -> Self

Build a non-empty pointer with no extensions.

Source

pub fn empty() -> Self

The empty pointer (size 0, OID Oid::EMPTY, no extensions). This is the parse result for empty input and the pointer representation of an empty file.

Source

pub fn is_empty(&self) -> bool

true if this is the empty pointer (size 0).

Source

pub fn encode(&self) -> String

Encode to canonical text form. The empty pointer encodes to "".

Extensions are emitted sorted by priority. The version line is always VERSION_LATEST, regardless of what the source used.

Source

pub fn parse(input: &[u8]) -> Result<Self, DecodeError>

Parse a pointer from the raw bytes of a blob.

Returns DecodeError::NotAPointer if the input doesn’t look like a pointer at all (callers like the smudge filter should pass the bytes through unchanged), or DecodeError::Malformed if the input has pointer shape but invalid contents (callers should error out).

Trait Implementations§

Source§

impl Clone for Pointer

Source§

fn clone(&self) -> Pointer

Returns a duplicate 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 Pointer

Source§

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

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

impl PartialEq for Pointer

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Pointer

Source§

impl StructuralPartialEq for Pointer

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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