Skip to main content

Crate git_lfs_pointer

Crate git_lfs_pointer 

Source
Expand description

Parsing and encoding for git-lfs pointer files.

See docs/spec.md for the format. Briefly: a pointer is a tiny UTF-8 text file whose lines are sorted key value pairs, with version always first and the rest in alphabetical order, terminated by \n. The whole file must be < 1024 bytes.

use git_lfs_pointer::{Oid, Pointer};

let oid: Oid = "4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393"
    .parse()
    .unwrap();
let pointer = Pointer::new(oid, 12345);

let encoded = pointer.encode();
let parsed = Pointer::parse(encoded.as_bytes()).unwrap();
assert_eq!(parsed.oid, oid);
assert_eq!(parsed.size, 12345);
assert!(parsed.canonical);

Structs§

Extension
A pointer extension (see docs/extensions.md).
Oid
A SHA-256 object identifier.
Pointer
A parsed git-lfs pointer.

Enums§

DecodeError
MalformedReason
NotAPointerReason
OidParseError

Constants§

EMPTY_HEX
Hex form of the SHA-256 of the empty input. Used as the OID of the empty pointer (which represents an empty file — see docs/spec.md).
MAX_POINTER_SIZE
Pointer files must be smaller than this (per docs/spec.md). Inputs of this size or larger are not pointers.
VERSION_LATEST
The version URL we always emit. Older aliases parse but re-encode to this.