[][src]Struct hypercore::Feed

pub struct Feed<T> where
    T: RandomAccess<Error = Error> + Debug
{ /* fields omitted */ }

Append-only log structure.

Methods

impl<T> Feed<T> where
    T: RandomAccess<Error = Error> + Debug
[src]

pub fn with_storage(storage: Storage<T>) -> Result<Self>[src]

Create a new instance with a custom storage backend.

pub fn builder(public_key: PublicKey, storage: Storage<T>) -> FeedBuilder<T>[src]

Starts a FeedBuilder with the provided Keypair and Storage.

pub fn len(&self) -> usize[src]

Get the amount of entries in the feed.

pub fn is_empty(&self) -> bool[src]

Check if the length is 0.

pub fn byte_len(&self) -> usize[src]

Get the total amount of bytes stored in the feed.

pub fn append(&mut self, data: &[u8]) -> Result<()>[src]

Append data into the log.

pub fn head(&mut self) -> Result<Option<Vec<u8>>>[src]

Get the block of data at the tip of the feed. This will be the most recently appended block.

pub fn has(&mut self, index: usize) -> bool[src]

Return true if a data block is available locally.

pub fn has_all(&mut self, range: Range<usize>) -> bool[src]

Return true if all data blocks within a range are available locally.

pub fn downloaded(&mut self, range: Range<usize>) -> u8[src]

Get the total amount of chunks downloaded.

pub fn get(&mut self, index: usize) -> Result<Option<Vec<u8>>>[src]

Retrieve data from the log.

pub fn proof(&mut self, index: usize, include_hash: bool) -> Result<Proof>[src]

Return the Nodes which prove the correctness for the Node at index.

pub fn proof_with_digest(
    &mut self,
    index: usize,
    digest: usize,
    include_hash: bool
) -> Result<Proof>
[src]

Return the Nodes which prove the correctness for the Node at index with a digest.

pub fn digest(&mut self, index: usize) -> usize[src]

Compute the digest for the index.

pub fn put(
    &mut self,
    index: usize,
    data: Option<&[u8]>,
    proof: Proof
) -> Result<()>
[src]

Insert data into the tree at index. Verifies the proof when inserting to make sure data is correct. Useful when replicating data from a remote host.

pub fn signature(&mut self, index: usize) -> Result<Signature>[src]

Get a signature from the store.

pub fn verify(&mut self, index: usize, signature: &Signature) -> Result<()>[src]

Verify the entire feed. Checks a signature against the signature of all root nodes combined.

pub fn announce(&mut self, message: &Message, from: &Peer)[src]

Announce we have a piece of data to all other peers.

pub fn unannounce(&mut self, message: &Message)[src]

Announce we no longer have a piece of data to all other peers.

pub fn root_hashes(&mut self, index: usize) -> Result<Vec<Node>>[src]

Get all root hashes from the feed.

pub fn public_key(&self) -> &PublicKey[src]

Access the public key.

pub fn secret_key(&self) -> &Option<SecretKey>[src]

Access the secret key.

pub fn audit(&mut self) -> Result<Audit>[src]

Audit all data in the feed. Checks that all current data matches the hashes in the merkle tree, and clears the bitfield if not. The tuple returns is (valid_blocks, invalid_blocks)

pub fn download(&mut self, _range: Range<usize>) -> Result<()>[src]

(unimplemented) Provide a range of data to download.

pub fn undownload(&mut self, _range: Range<usize>) -> Result<()>[src]

(unimplemented) Provide a range of data to remove from the local storage.

pub fn finalize(&mut self) -> Result<()>[src]

(unimplemented) End the feed.

pub fn update_peers(&mut self)[src]

Update all peers.

impl Feed<RandomAccessDisk>[src]

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>[src]

Create a new instance that persists to disk at the location of dir.

Trait Implementations

impl<T: Debug> Debug for Feed<T> where
    T: RandomAccess<Error = Error> + Debug
[src]

impl Default for Feed<RandomAccessMemory>[src]

Create a new instance with an in-memory storage backend.

Panics

Can panic if constructing the in-memory store fails, which is highly unlikely.

impl<T: RandomAccess<Error = Error> + Debug> Display for Feed<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Feed<T> where
    T: RefUnwindSafe

impl<T> Send for Feed<T> where
    T: Send

impl<T> Sync for Feed<T> where
    T: Sync

impl<T> Unpin for Feed<T> where
    T: Unpin

impl<T> UnwindSafe for Feed<T> where
    T: UnwindSafe

Blanket Implementations

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

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

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

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<T> From<T> for T[src]

impl<T> InitializableFromZeroed for T where
    T: Default

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.