Struct hypercore::Feed [−][src]
pub struct Feed<T> where
T: RandomAccessMethods<Error = Error> + Debug, { /* fields omitted */ }
Append-only log structure.
Methods
impl<T> Feed<T> where
T: RandomAccessMethods<Error = Error> + Debug,
[src]
impl<T> Feed<T> where
T: RandomAccessMethods<Error = Error> + Debug,
pub fn with_storage(storage: Storage<T>) -> Result<Self>
[src]
pub fn with_storage(storage: Storage<T>) -> Result<Self>
Create a new instance with a custom storage backend.
pub fn builder(public_key: PublicKey, storage: Storage<T>) -> FeedBuilder<T>
[src]
pub fn builder(public_key: PublicKey, storage: Storage<T>) -> FeedBuilder<T>
Starts a FeedBuilder
with the provided Keypair
and Storage
.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Get the amount of entries in the feed.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Check if the length is 0.
pub fn byte_len(&self) -> usize
[src]
pub fn byte_len(&self) -> usize
Get the total amount of bytes stored in the feed.
pub fn append(&mut self, data: &[u8]) -> Result<()>
[src]
pub fn append(&mut self, data: &[u8]) -> Result<()>
Append data into the log.
pub fn head(&mut self) -> Result<Option<Vec<u8>>>
[src]
pub fn head(&mut self) -> Result<Option<Vec<u8>>>
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]
pub fn has(&mut self, index: usize) -> bool
Return true
if a data block is available locally.
pub fn has_all(&mut self, range: Range<usize>) -> bool
[src]
pub fn has_all(&mut self, range: Range<usize>) -> bool
Return true
if all data blocks within a range are available locally.
pub fn downloaded(&mut self, range: Range<usize>) -> u8
[src]
pub fn downloaded(&mut self, range: Range<usize>) -> u8
Get the total amount of chunks downloaded.
pub fn get(&mut self, index: usize) -> Result<Option<Vec<u8>>>
[src]
pub fn get(&mut self, index: usize) -> Result<Option<Vec<u8>>>
Retrieve data from the log.
pub fn proof(&mut self, index: usize, include_hash: bool) -> Result<Proof>
[src]
pub fn proof(&mut self, index: usize, include_hash: bool) -> Result<Proof>
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]
pub fn proof_with_digest(
&mut self,
index: usize,
digest: usize,
include_hash: bool
) -> Result<Proof>
pub fn digest(&mut self, index: usize) -> usize
[src]
pub fn digest(&mut self, index: usize) -> usize
Compute the digest for the index.
pub fn put(
&mut self,
index: usize,
data: Option<&[u8]>,
proof: Proof
) -> Result<()>
[src]
pub fn put(
&mut self,
index: usize,
data: Option<&[u8]>,
proof: Proof
) -> Result<()>
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]
pub fn signature(&mut self, index: usize) -> Result<Signature>
Get a signature from the store.
pub fn verify(&mut self, index: usize, signature: &Signature) -> Result<()>
[src]
pub fn verify(&mut self, index: usize, signature: &Signature) -> Result<()>
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]
pub fn announce(&mut self, message: &Message, from: &Peer)
Announce we have a piece of data to all other peers.
pub fn unannounce(&mut self, message: &Message)
[src]
pub fn unannounce(&mut self, message: &Message)
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]
pub fn root_hashes(&mut self, index: usize) -> Result<Vec<Node>>
Get all root hashes from the feed.
pub fn public_key(&self) -> &PublicKey
[src]
pub fn public_key(&self) -> &PublicKey
Access the public key.
pub fn secret_key(&self) -> &Option<SecretKey>
[src]
pub fn secret_key(&self) -> &Option<SecretKey>
Access the secret key.
pub fn download(&mut self, _range: Range<usize>) -> Result<()>
[src]
pub fn download(&mut self, _range: Range<usize>) -> Result<()>
(unimplemented) Provide a range of data to download.
pub fn undownload(&mut self, _range: Range<usize>) -> Result<()>
[src]
pub fn undownload(&mut self, _range: Range<usize>) -> Result<()>
(unimplemented) Provide a range of data to remove from the local storage.
pub fn finalize(&mut self) -> Result<()>
[src]
pub fn finalize(&mut self) -> Result<()>
(unimplemented) End the feed.
pub fn update_peers(&mut self)
[src]
pub fn update_peers(&mut self)
Update all peers.
impl Feed<RandomAccessDiskMethods>
[src]
impl Feed<RandomAccessDiskMethods>
pub fn new(dir: &PathBuf) -> Result<Self>
[src]
pub fn new(dir: &PathBuf) -> Result<Self>
Create a new instance that persists to disk at the location of dir
.
Trait Implementations
impl<T: Debug> Debug for Feed<T> where
T: RandomAccessMethods<Error = Error> + Debug,
[src]
impl<T: Debug> Debug for Feed<T> where
T: RandomAccessMethods<Error = Error> + Debug,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for Feed<RandomAccessMemoryMethods>
[src]
impl Default for Feed<RandomAccessMemoryMethods>
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: RandomAccessMethods<Error = Error> + Debug> Display for Feed<T>
[src]
impl<T: RandomAccessMethods<Error = Error> + Debug> Display for Feed<T>