Expand description
File splitting and joining for arbitrary-size data.
Async is the primary API. SyncJoiner implements Read + Seek, SyncSplitter
implements Write.
§Store-centric API (extension traits)
use nectar_primitives::file::{SyncChunkGetExt, SyncChunkPutExt};
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 data = store.read_file(addr).unwrap();
assert_eq!(data, b"hello swarm");§Free function API
use nectar_primitives::file::{sync_split, sync_join};
use nectar_primitives::DEFAULT_BODY_SIZE;
let data = b"Hello, Swarm!";
let (root, store) = sync_split::<DEFAULT_BODY_SIZE>(data).unwrap();
let recovered = sync_join(&store, root).unwrap();
assert_eq!(recovered, data);§Encrypted split and join
use nectar_primitives::file::{sync_split_encrypted, sync_join};
use nectar_primitives::DEFAULT_BODY_SIZE;
let data = b"secret data";
let (root_ref, store) = sync_split_encrypted::<DEFAULT_BODY_SIZE>(data).unwrap();
let recovered = sync_join(&store, root_ref).unwrap();
assert_eq!(recovered, data);Re-exports§
Modules§
- entry_
ref - Unified file entry reference type.
- error
- Error types for file splitting and joining operations.
- mode
- Chunk mode traits for plain and encrypted file operations.
Structs§
- Chunk
Range - Range of chunk indices.
- Generic
Joiner - Generic async joiner parameterized by chunk mode.
- Generic
Sync Joiner - Generic joiner parameterized by chunk mode.
- Joiner
Reader - Wrapper providing
tokio::io::AsyncReadover aGenericJoiner. - Tree
Params - Tree structure for a file of known size.
Traits§
- Chunk
GetExt - Extension methods for async chunk getters.
- JoinRef
- Maps a reference type to its join mode.
Sealed — implemented for
ChunkAddressandEncryptedChunkRef. - Sync
Chunk GetExt - Extension methods for sync chunk getters.
- Sync
Chunk PutExt - Extension methods for sync chunk putters.
- Sync
Read At - Sync data source supporting offset-based reads.
Functions§
- join
- Join chunks asynchronously. Dispatches plain/encrypted via
JoinRef. - sync_
join - Join chunks synchronously. Dispatches plain/encrypted via
JoinRef. - sync_
split - Split data into chunks synchronously, returning root address and chunk store.
- sync_
split_ encrypted - Split data into encrypted chunks synchronously.
Type Aliases§
- Encrypted
Joiner - Encrypted async joiner.
- Encrypted
Sync Joiner - Encrypted file joiner.
- Encrypted
Sync Parallel Splitter - Encrypted parallel splitter.
- Encrypted
Sync Splitter - Encrypted file splitter.
- Joiner
- Plain (unencrypted) async joiner.
- Sync
Joiner - Plain (unencrypted) file joiner.
- Sync
Parallel Splitter - Plain (unencrypted) parallel splitter.
- Sync
Splitter - Plain (unencrypted) file splitter.