[−][src]Struct hypercore::Feed
Append-only log structure.
Methods
impl<T> Feed<T> where
T: RandomAccess<Error = Error> + Debug, [src]
impl<T> Feed<T> where
T: RandomAccess<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) -> usizeGet the amount of entries in the feed.
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolCheck if the length is 0.
pub fn byte_len(&self) -> usize[src]
pub fn byte_len(&self) -> usizeGet 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) -> boolReturn 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>) -> boolReturn 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>) -> u8Get 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>Return the Nodes which prove the correctness for the Node at index with a digest.
pub fn digest(&mut self, index: usize) -> usize[src]
pub fn digest(&mut self, index: usize) -> usizeCompute 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) -> &PublicKeyAccess 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<RandomAccessDisk>[src]
impl Feed<RandomAccessDisk>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 Default for Feed<RandomAccessMemory>[src]
impl Default for Feed<RandomAccessMemory>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: Debug> Debug for Feed<T> where
T: RandomAccess<Error = Error> + Debug, [src]
impl<T: Debug> Debug for Feed<T> where
T: RandomAccess<Error = Error> + Debug, fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<T: RandomAccess<Error = Error> + Debug> Display for Feed<T>[src]
impl<T: RandomAccess<Error = Error> + Debug> Display for Feed<T>Auto Trait Implementations
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized, [src]
impl<T> ToString for T where
T: Display + ?Sized, impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized,
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized, fn clear(&mut self)
fn clear(&mut self)Completely overwrites this value.
impl<T> InitializableFromZeroed for T where
T: Default,
impl<T> InitializableFromZeroed for T where
T: Default, unsafe fn initialize(place: *mut T)
unsafe fn initialize(place: *mut T)Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more
impl<T> Same for T
impl<T> Same for Ttype Output = T
Should always be Self