[][src]Crate nip_core

nip_core is a library that lets you interact with nip repositories programmatically.

extern crate failure;
extern crate git2;
extern crate ipfs_api;
extern crate nip_core;

use failure::Error;
use git2::Repository;
use ipfs_api::IpfsClient;
use nip_core::{NIPIndex, NIPRemote};

// Open the local repository
let mut repo = Repository::open_from_env()?;

// Get a handle for IPFS API
let mut ipfs = IpfsClient::default();

// Instantiate a brand new nip index
let mut idx = NIPIndex::from_nip_remote(&NIPRemote::NewIPFS, &mut ipfs)?;

// Upload the full object tree behind a specified local ref to IPFS
idx.push_ref_from_str("refs/heads/master", "refs/heads/master", false, &mut repo, &mut ipfs)?;

// Also upload the brand new index itself
let nip_remote: NIPRemote = idx.ipfs_add(&mut ipfs, None)?;

println!("Success! refs/heads/master uploaded to remote {}", nip_remote.to_string());

Re-exports

pub use crate::constants::*;
pub use crate::error::*;
pub use crate::index::*;
pub use crate::object::*;
pub use crate::remote::*;
pub use crate::util::*;
pub use crate::migrations::*;

Modules

constants

Constants used by nip_core.

error

Error types

index

nip index implementation

migrations

A collection of migration helpers for keeping older nip repos relevant; controlled by the migrations feature.`

object

nip object implementation

remote

nip remote implementation

util

Utility routines that don't necessarily fit anywhere else.