Enum swh_graph::SWHType

source ·
#[repr(u8)]
pub enum SWHType { Content = 0, Directory = 1, Origin = 2, Release = 3, Revision = 4, Snapshot = 5, }
Expand description

Variants§

§

Content = 0

§

Directory = 1

a list of named directory entries, each of which pointing to other artifacts, usually file contents or sub-directories. Directory entries are also associated to some metadata stored as permission bits.

§

Origin = 2

code “hosting places” as previously described are usually large platforms that host several unrelated software projects. For software provenance purposes it is important to be more specific than that.

Software origins are fine grained references to where source code artifacts archived by Software Heritage have been retrieved from. They take the form of (type, url) pairs, where url is a canonical URL (e.g., the address at which one can git clone a repository or download a source tarball) and type the kind of software origin (e.g., git, svn, or dsc for Debian source packages).

§

Release = 3

AKA “tags”

some revisions are more equals than others and get selected by developers as denoting important project milestones known as “releases”. Each release points to the last commit in project history corresponding to the release and carries metadata: release name and version, release message, cryptographic signatures, etc.

§

Revision = 4

AKA commits

Software development within a specific project is essentially a time-indexed series of copies of a single “root” directory that contains the entire project source code. Software evolves when a d eveloper modifies the content of one or more files in that directory and record their changes.

Each recorded copy of the root directory is known as a “revision”. It points to a fully-determined directory and is equipped with arbitrary metadata. Some of those are added manually by the developer (e.g., commit message), others are automatically synthesized (timestamps, preceding commit(s), etc).

§

Snapshot = 5

any kind of software origin offers multiple pointers to the “current” state of a development project. In the case of VCS this is reflected by branches (e.g., master, development, but also so called feature branches dedicated to extending the software in a specific direction); in the case of package distributions by notions such as suites that correspond to different maturity levels of individual packages (e.g., stable, development, etc.).

A “snapshot” of a given software origin records all entry points found there and where each of them was pointing at the time. For example, a snapshot object might track the commit where the master branch was pointing to at any given time, as well as the most recent release of a given package in the stable suite of a FOSS distribution.

Implementations§

source§

impl SWHType

source

pub const NUMBER_OF_TYPES: usize = 6usize

Get the number of possible types.

To avoid having to update this when adding a new type we can use the unstable function std::mem::variant_count or the variant_count crate. But for now we just hardcode it while we decide how to deal with this.

source

pub const BITWIDTH: usize = 3usize

The number of bits needed to store the node type as integers This is ceil(log2(NUMBER_OF_TYPES)) which can be arithmetized into floor(log2(NUMBER_OF_TYPES)) plus one if it’s not a power of two.

source

pub fn to_str(&self) -> &'static str

Convert a type to the str used in the SWHID

source

pub fn all() -> Vec<Self>

Returns a vector containing all possible SWHType values.

Trait Implementations§

source§

impl Clone for SWHType

source§

fn clone(&self) -> SWHType

Returns a copy 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 SWHType

source§

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

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

impl Display for SWHType

source§

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

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

impl Hash for SWHType

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for SWHType

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> TryFrom<&'a [u8]> for SWHType

§

type Error = &'a [u8]

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a [u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a str> for SWHType

§

type Error = &'a str

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a str) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<u8> for SWHType

§

type Error = u8

The type returned in the event of a conversion error.
source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for SWHType

source§

impl Eq for SWHType

source§

impl StructuralEq for SWHType

source§

impl StructuralPartialEq for SWHType

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsOut<T> for Twhere T: Copy,

§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CastableFrom<T> for T

§

fn cast_from(value: T) -> T

Call Self as W
§

impl<T, U> CastableInto<U> for Twhere U: CastableFrom<T>,

§

fn cast(self) -> U

Call W::cast_from(self)
§

impl<T> DowncastableFrom<T> for T

§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
§

impl<T, U> DowncastableInto<U> for Twhere U: DowncastableFrom<T>,

§

fn downcast(self) -> U

Call W::downcast_from(self)
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for Twhere W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for Twhere T: ?Sized,

§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Splat<T> for T

§

fn splat(value: T) -> T

§

impl<T> To<T> for T

§

fn to(self) -> T

source§

impl<T> ToOwned for Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<T> UpcastableFrom<T> for T

§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
§

impl<T, U> UpcastableInto<U> for Twhere U: UpcastableFrom<T>,

§

fn upcast(self) -> U

Call W::upcast_from(self)
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Allocation for Twhere T: RefUnwindSafe + Send + Sync,

§

impl<T> Sequence for Twhere T: Eq + Hash,