[−][src]Struct hypercore::prelude::Storage
Save data to a desired storage backend.
Implementations
impl<T> Storage<T> where
T: RandomAccess<Error = Box<dyn Error + Send + Sync>> + Debug + Send,
[src]
T: RandomAccess<Error = Box<dyn Error + Send + Sync>> + Debug + Send,
pub async fn new<Cb>(create: Cb) -> Result<Self> where
Cb: Fn(Store) -> Pin<Box<dyn Future<Output = Result<T>> + Send>>,
[src]
Cb: Fn(Store) -> Pin<Box<dyn Future<Output = Result<T>> + Send>>,
Create a new instance. Takes a keypair and a callback to create new storage instances.
pub async fn write_data<'_, '_>(
&'_ mut self,
offset: u64,
data: &'_ [u8]
) -> Result<()>
[src]
&'_ mut self,
offset: u64,
data: &'_ [u8]
) -> Result<()>
Write data to the feed.
pub async fn put_data<'_, '_, '_>(
&'_ mut self,
index: u64,
data: &'_ [u8],
nodes: &'_ [Node]
) -> Result<()>
[src]
&'_ mut self,
index: u64,
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 async fn get_data<'_>(&'_ mut self, index: u64) -> Result<Vec<u8>>
[src]
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<'a>(
&'a mut self,
index: u64
) -> BoxFuture<'a, Result<Signature>>
[src]
&'a mut self,
index: u64
) -> BoxFuture<'a, Result<Signature>>
Search the signature stores for a Signature
, starting at index
.
pub async fn get_signature<'_>(&'_ mut self, index: u64) -> Result<Signature>
[src]
Get a Signature
from the store.
pub async fn put_signature<'_>(
&'_ mut self,
index: u64,
signature: impl Borrow<Signature>
) -> Result<()>
[src]
&'_ mut self,
index: u64,
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 async fn data_offset<'_, '_>(
&'_ mut self,
index: u64,
cached_nodes: &'_ [Node]
) -> Result<Range<u64>>
[src]
&'_ mut self,
index: u64,
cached_nodes: &'_ [Node]
) -> Result<Range<u64>>
TODO(yw) docs
Get the offset for the data, return (offset, size)
.
Panics
A panic can occur if no maximum value is found.
pub async fn get_node<'_>(&'_ mut self, index: u64) -> Result<Node>
[src]
Get a Node
from the tree
storage.
pub async fn put_node<'_, '_>(&'_ mut self, node: &'_ Node) -> Result<()>
[src]
Write a Node
to the tree
storage.
TODO: prevent extra allocs here. Implement a method on node that can reuse
a buffer.
pub async fn put_bitfield<'_, '_>(
&'_ mut self,
offset: u64,
data: &'_ [u8]
) -> Result<()>
[src]
&'_ mut self,
offset: u64,
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 async fn read_public_key<'_>(&'_ mut self) -> Result<PublicKey>
[src]
Read a public key from storage
pub async fn read_secret_key<'_>(&'_ mut self) -> Result<SecretKey>
[src]
Read a secret key from storage
pub async fn write_public_key<'_, '_>(
&'_ mut self,
public_key: &'_ PublicKey
) -> Result<()>
[src]
&'_ mut self,
public_key: &'_ PublicKey
) -> Result<()>
Write a public key to the storage
pub async fn write_secret_key<'_, '_>(
&'_ mut self,
secret_key: &'_ SecretKey
) -> Result<()>
[src]
&'_ mut self,
secret_key: &'_ SecretKey
) -> Result<()>
Write a secret key to the storage
pub async fn read_partial_keypair<'_>(&'_ mut self) -> Option<PartialKeypair>
[src]
Tries to read a partial keypair (ie: with an optional secret_key) from the storage
impl Storage<RandomAccessMemory>
[src]
pub async fn new_memory() -> Result<Self>
[src]
Create a new instance backed by a RandomAccessMemory
instance.
impl Storage<RandomAccessDisk>
[src]
pub async fn new_disk<'_>(dir: &'_ PathBuf) -> Result<Self>
[src]
Create a new instance backed by a RandomAccessDisk
instance.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Storage<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Storage<T> where
T: Send,
T: Send,
impl<T> Sync for Storage<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Storage<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Storage<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,