Skip to main content

SyncChunkGetExt

Trait SyncChunkGetExt 

Source
pub trait SyncChunkGetExt<const BODY_SIZE: usize>: SyncChunkGet<BODY_SIZE> {
    // Provided methods
    fn joiner<R: JoinRef>(
        self,
        root: R,
    ) -> Result<GenericSyncJoiner<Self, R::Mode, BODY_SIZE>>
       where Self: Clone + Send + Sync + Sized { ... }
    fn read_file<R: JoinRef>(self, root: R) -> Result<Vec<u8>>
       where Self: Clone + Send + Sync + Sized { ... }
}
Expand description

Extension methods for sync chunk getters.

Automatically implemented for all types that implement SyncChunkGet. Uses JoinRef for unified plain/encrypted dispatch.

use nectar_primitives::file::{SyncChunkPutExt, SyncChunkGetExt};
use nectar_primitives::store::MemoryStore;
use nectar_primitives::DEFAULT_BODY_SIZE;

let store = MemoryStore::<DEFAULT_BODY_SIZE>::new();
let addr = store.write_file(b"hello swarm").unwrap();
let recovered = store.read_file(addr).unwrap();
assert_eq!(recovered, b"hello swarm");

Provided Methods§

Source

fn joiner<R: JoinRef>( self, root: R, ) -> Result<GenericSyncJoiner<Self, R::Mode, BODY_SIZE>>
where Self: Clone + Send + Sync + Sized,

Open a file for reading. Returns a joiner implementing Read + Seek.

Source

fn read_file<R: JoinRef>(self, root: R) -> Result<Vec<u8>>
where Self: Clone + Send + Sync + Sized,

Read entire file into memory (like fs::read).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, const BODY_SIZE: usize> SyncChunkGetExt<BODY_SIZE> for T
where T: SyncChunkGet<BODY_SIZE>,