[][src]Struct nip_core::index::NIPIndex

pub struct NIPIndex {
    pub refs: BTreeMap<String, String>,
    pub objects: BTreeMap<String, String>,
    pub prev_idx_hash: Option<String>,
}

The entrypoint data structure for every nip repo.

Every top-level nip IPFS link points at a NIPIndex. nip indices store information about all git objects contained within a given nip repository.

Fields

refs: BTreeMap<String, String>

All refs this repository knows; a {name -> sha1} mapping

objects: BTreeMap<String, String>

All objects this repository contains; a {sha1 -> IPFS hash} map

prev_idx_hash: Option<String>

The IPFS hash of the previous index

Methods

impl NIPIndex[src]

pub fn from_nip_remote(
    remote: &NIPRemote,
    ipfs: &mut IpfsClient
) -> Result<Self, Error>
[src]

Download from IPFS and instantiate a NIPIndex

pub fn from_slice(bytes: &[u8]) -> Result<Self, Error>[src]

Take raw index bytes and build a NIPIndex from it

pub fn push_ref_from_str(
    &mut self,
    ref_src: &str,
    ref_dst: &str,
    force: bool,
    repo: &mut Repository,
    ipfs: &mut IpfsClient
) -> Result<(), Error>
[src]

Figure out what git hash ref_src points to in repo and add it to the index as ref_dst. If ref_src is an empty string, ref_dst is deleted from the index (only the ref, the objects aren't touched).

pub fn enumerate_for_push(
    &self,
    obj: &Object,
    push_todo: &mut HashSet<Oid>,
    submodules: &mut HashSet<Oid>,
    repo: &Repository
) -> Result<(), Error>
[src]

Iteratively fill two hash sets: obj's children present in repo but missing from self (push_todo), and obj's children recognized as submodule tips. (submodules).

pub fn push_git_objects(
    &mut self,
    oids: &HashSet<Oid>,
    repo: &Repository,
    ipfs: &mut IpfsClient
) -> Result<(), Error>
[src]

Take oids and upload underlying repo git objects to IPFS. for submodules the SUBMODULE_TIP_MARKER is inserted.

pub fn fetch_to_ref_from_str(
    &self,
    git_hash: &str,
    ref_name: &str,
    repo: &mut Repository,
    ipfs: &mut IpfsClient
) -> Result<(), Error>
[src]

Fetch git_hash from self to repo's ref_name ref.

pub fn enumerate_for_fetch(
    &self,
    oid: Oid,
    fetch_todo: &mut HashSet<Oid>,
    repo: &Repository,
    ipfs: &mut IpfsClient
) -> Result<(), Error>
[src]

Fill a hash set with oid's children that are present in self but missing in repo.

pub fn fetch_nip_objects(
    &self,
    oids: &HashSet<Oid>,
    repo: &mut Repository,
    ipfs: &mut IpfsClient
) -> Result<(), Error>
[src]

Download git objects in oids from IPFS and instantiate them in repo.

pub fn ipfs_add(
    &mut self,
    ipfs: &mut IpfsClient,
    prev_remote: Option<&NIPRemote>
) -> Result<NIPRemote, Error>
[src]

Upload self to IPFS and return the IPFS/IPNS link. Plain/IPNS link use is determined as per prev_remote variant (IPNS is used for both NewIPNS and ExistingIPNS, None assumes IPFS); prev_remote is later put in the prev_idx_hash field just before upload.

Trait Implementations

impl PartialEq<NIPIndex> for NIPIndex[src]

impl Clone for NIPIndex[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for NIPIndex[src]

impl Debug for NIPIndex[src]

impl Hash for NIPIndex[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

impl Serialize for NIPIndex[src]

impl<'de> Deserialize<'de> for NIPIndex[src]

Auto Trait Implementations

impl Send for NIPIndex

impl Sync for NIPIndex

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> Erased for T

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Same for T

type Output = T

Should always be Self