Xgit v0.3.0 Xgit.Core.ObjectId View Source

An object ID is a string that identifies an object within a repository.

This string must match the format for a SHA-1 hash (i.e. 40 characters of lowercase hex).

Link to this section Summary

Types

t()

A string containing 40 bytes of lowercase hex digits.

Functions

Assign an object ID for a given data blob.

Read an object ID from raw binary or bytelist.

Read an object ID from a hex string (charlist).

Convert an object ID to raw binary representation.

Returns true if the value is a valid object ID.

Get the special all-null object ID, often used to stand-in for no object.

Link to this section Types

A string containing 40 bytes of lowercase hex digits.

Link to this section Functions

Link to this function

calculate_id(data, type)

View Source
calculate_id(
  data :: Xgit.Core.ContentSource.t(),
  type :: Xgit.Core.ObjectType.t()
) :: t()

Assign an object ID for a given data blob.

No validation is performed on the content.

Parameters

Return Value

The object ID. (See Xgit.Core.ObjectId.)

Link to this function

from_binary_iodata(b)

View Source
from_binary_iodata(b :: iodata()) :: t()

Read an object ID from raw binary or bytelist.

Parameters

raw_object_id should be either a binary or list containing a raw object ID (not hex-encoded). It should be exactly 20 bytes.

Return Value

The object ID rendered as lowercase hex. (See Xgit.Core.ObjectId.)

Link to this function

from_hex_charlist(b)

View Source
from_hex_charlist(b :: charlist()) :: {t(), charlist()} | false

Read an object ID from a hex string (charlist).

Return Value

If a valid ID is found, returns {id, next} where id is the matched ID as a string and next is the remainder of the charlist after the matched ID.

If no such ID is found, returns false.

Link to this function

to_binary_iodata(id)

View Source
to_binary_iodata(id :: t()) :: binary()

Convert an object ID to raw binary representation.

Return Value

A 20-byte binary encoding the object ID.

Link to this function

valid?(id)

View Source
valid?(id :: term()) :: boolean()

Returns true if the value is a valid object ID.

(In other words, is it a string containing 40 characters of lowercase hex?)

Get the special all-null object ID, often used to stand-in for no object.