[−][src]Struct hypercore::Storage
Save data to a desired storage backend.
Methods
impl<T> Storage<T> where
T: RandomAccess<Error = Error> + Debug, [src]
impl<T> Storage<T> where
T: RandomAccess<Error = Error> + Debug, pub fn new<Cb>(create: Cb) -> Result<Self> where
Cb: Fn(Store) -> Result<T>, [src]
pub fn new<Cb>(create: Cb) -> Result<Self> where
Cb: Fn(Store) -> Result<T>, Create a new instance. Takes a keypair and a callback to create new storage instances.
pub fn write_data(&mut self, offset: usize, data: &[u8]) -> Result<()>[src]
pub fn write_data(&mut self, offset: usize, data: &[u8]) -> Result<()>Write data to the feed.
pub fn put_data(
&mut self,
index: usize,
data: &[u8],
nodes: &[Node]
) -> Result<()>[src]
pub fn put_data(
&mut self,
index: usize,
data: &[u8],
nodes: &[Node]
) -> Result<()>Write a byte vector to a data storage (random-access instance) at the
position of index.
NOTE: Meant to be called from the .put() feed method. Probably used to
insert data as-is after receiving it from the network (need to confirm
with mafintosh).
TODO: Ensure the signature size is correct.
NOTE: Should we create a Data entry type?
pub fn get_data(&mut self, index: usize) -> Result<Vec<u8>>[src]
pub fn get_data(&mut self, index: usize) -> Result<Vec<u8>>Get data from disk that the user has written to it. This is stored unencrypted, so there's no decryption needed.
pub fn next_signature(&mut self, index: usize) -> Result<Signature>[src]
pub fn next_signature(&mut self, index: usize) -> Result<Signature>Search the signature stores for a Signature, starting at index.
pub fn get_signature(&mut self, index: usize) -> Result<Signature>[src]
pub fn get_signature(&mut self, index: usize) -> Result<Signature>Get a Signature from the store.
pub fn put_signature(
&mut self,
index: usize,
signature: impl Borrow<Signature>
) -> Result<()>[src]
pub fn put_signature(
&mut self,
index: usize,
signature: impl Borrow<Signature>
) -> Result<()>Write a Signature to self.Signatures.
TODO: Ensure the signature size is correct.
NOTE: Should we create a Signature entry type?
pub fn data_offset(
&mut self,
index: usize,
cached_nodes: &[Node]
) -> Result<Range<usize>>[src]
pub fn data_offset(
&mut self,
index: usize,
cached_nodes: &[Node]
) -> Result<Range<usize>>TODO(yw) docs
Get the offset for the data, return (offset, size).
Panics
A panic can occur if no maximum value is found.
pub fn get_node(&mut self, index: usize) -> Result<Node>[src]
pub fn get_node(&mut self, index: usize) -> Result<Node>Get a Node from the tree storage.
pub fn put_node(&mut self, node: &Node) -> Result<()>[src]
pub fn put_node(&mut self, node: &Node) -> Result<()>Write a Node to the tree storage.
TODO: prevent extra allocs here. Implement a method on node that can reuse
a buffer.
pub fn put_bitfield(&mut self, offset: usize, data: &[u8]) -> Result<()>[src]
pub fn put_bitfield(&mut self, offset: usize, data: &[u8]) -> Result<()>Write data to the internal bitfield module. TODO: Ensure the chunk size is correct. NOTE: Should we create a bitfield entry type?
pub fn read_public_key(&mut self) -> Result<PublicKey>[src]
pub fn read_public_key(&mut self) -> Result<PublicKey>Read a public key from storage
pub fn read_secret_key(&mut self) -> Result<SecretKey>[src]
pub fn read_secret_key(&mut self) -> Result<SecretKey>Read a secret key from storage
pub fn write_public_key(&mut self, public_key: &PublicKey) -> Result<()>[src]
pub fn write_public_key(&mut self, public_key: &PublicKey) -> Result<()>Write a public key to the storage
pub fn write_secret_key(&mut self, secret_key: &SecretKey) -> Result<()>[src]
pub fn write_secret_key(&mut self, secret_key: &SecretKey) -> Result<()>Write a secret key to the storage
pub fn read_partial_keypair(&mut self) -> Option<PartialKeypair>[src]
pub fn read_partial_keypair(&mut self) -> Option<PartialKeypair>Tries to read a partial keypair (ie: with an optional secret_key) from the storage
impl Storage<RandomAccessMemory>[src]
impl Storage<RandomAccessMemory>pub fn new_memory() -> Result<Self>[src]
pub fn new_memory() -> Result<Self>Create a new instance backed by a RandomAccessMemory instance.
impl Storage<RandomAccessDisk>[src]
impl Storage<RandomAccessDisk>pub fn new_disk(dir: &PathBuf) -> Result<Self>[src]
pub fn new_disk(dir: &PathBuf) -> Result<Self>Create a new instance backed by a RandomAccessDisk instance.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
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> Same for T
impl<T> Same for Ttype Output = T
Should always be Self