pub trait SyncChunkPutExt<const BODY_SIZE: usize>: SyncChunkPut<BODY_SIZE> {
// Provided methods
fn writer(&self, size: u64) -> SyncSplitter<&Self, BODY_SIZE>
where Self: Sized { ... }
fn encrypted_writer(
&self,
size: u64,
) -> EncryptedSyncSplitter<&Self, BODY_SIZE>
where Self: Sized { ... }
fn write_file(&self, data: &[u8]) -> Result<ChunkAddress>
where Self: Send + Sync + Sized { ... }
fn write_encrypted_file(&self, data: &[u8]) -> Result<EncryptedChunkRef>
where Self: Send + Sync + Sized { ... }
}Expand description
Extension methods for sync chunk putters.
Automatically implemented for all types that implement SyncChunkPut.
use nectar_primitives::file::{SyncChunkPutExt, SyncChunkGetExt};
use nectar_primitives::store::MemoryStore;
use nectar_primitives::DEFAULT_BODY_SIZE;
use std::io::Write;
// Filesystem-style write/read
let store = MemoryStore::<DEFAULT_BODY_SIZE>::new();
let addr = store.write_file(b"hello").unwrap();
// Streaming write via std::io::Write
let mut writer = store.writer(6);
writer.write_all(b"world!").unwrap();
let (root, _) = writer.finish().unwrap();Provided Methods§
Sourcefn writer(&self, size: u64) -> SyncSplitter<&Self, BODY_SIZE>where
Self: Sized,
fn writer(&self, size: u64) -> SyncSplitter<&Self, BODY_SIZE>where
Self: Sized,
Create a writer for streaming data. Returns a SyncSplitter implementing Write.
Call .finish() on the returned writer to get the root address.
Sourcefn encrypted_writer(&self, size: u64) -> EncryptedSyncSplitter<&Self, BODY_SIZE>where
Self: Sized,
fn encrypted_writer(&self, size: u64) -> EncryptedSyncSplitter<&Self, BODY_SIZE>where
Self: Sized,
Create an encrypted writer. Returns an EncryptedSyncSplitter implementing Write.
Sourcefn write_file(&self, data: &[u8]) -> Result<ChunkAddress>
fn write_file(&self, data: &[u8]) -> Result<ChunkAddress>
Write file data into the store (like fs::write).
Sourcefn write_encrypted_file(&self, data: &[u8]) -> Result<EncryptedChunkRef>
fn write_encrypted_file(&self, data: &[u8]) -> Result<EncryptedChunkRef>
Write encrypted file data into the store.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".