Skip to main content

Module file

Module file 

Source
Expand description

File / data / chunk / SOC / feed / collection uploads and downloads. Mirrors pkg/file in bee-go.

Get a FileApi from crate::Client::file.

§Streaming vs. buffered transfers

FileApi::download_data / FileApi::download_file buffer the full body into bytes::Bytes before returning — fine for ≤ a few hundred MB but will OOM on multi-GB references. For larger downloads, use FileApi::download_data_response (or download_file_response) which returns the raw reqwest::Response so you can drive reqwest::Response::bytes_stream yourself.

Uploads accept impl Into<Bytes> and stream the body to Bee. The chunk-by-chunk variants (FileApi::stream_directory and FileApi::stream_collection_entries) bound peak memory at the BMT chunk size regardless of file size and report progress via a caller-supplied OnStreamProgressFn.

§Cancellation

Dropping the future returned by any upload / download cancels the in-flight HTTP request. For FileApi::stream_directory and FileApi::stream_collection_entries, chunks already accepted by the local Bee node remain in the local reserve but the manifest is not finalized — the resulting orphan chunks are eventually pruned but cost reserve space until then.

Structs§

ChunkStream
Active /chunks/stream upload session. Open one via FileApi::chunks_stream.
CollectionEntry
One entry of an in-memory collection: a tar path plus its raw bytes. Mirrors bee-go’s CollectionEntry and bee-js’s Collection items.
FeedReader
Reader bound to a (owner, topic) pair. Wraps the lower-level FileApi feed methods for callers that prefer the bee-js FeedReader shape.
FeedUpdate
Result of a feed lookup: the wrapped chunk payload plus the indexes parsed from swarm-feed-index / swarm-feed-index-next.
FeedWriter
Writer bound to a (signer, topic) pair. Owner is derived from the signer.
FileApi
Handle exposing the file/data/chunk endpoints. Cheap to clone (holds an Arc<Inner>).
ReferenceInformation
Result of FileApi::probe_data: the size of the data behind a /bytes reference, learned via HEAD without downloading the body.
SocReader
Reader for SOCs owned by a known EthAddress. Fetches each chunk by computing its keccak256(identifier || owner) address and verifying the recovered signer matches the owner.
SocWriter
Reader + writer for SOCs signed by a known PrivateKey.
StreamProgress
Per-chunk upload signal emitted by FileApi::stream_directory. Mirrors bee-js UploadProgress.

Functions§

collection_size
Cumulative byte size of the entries’ data — equivalent to bee-js getCollectionSize.
feed_update_chunk_reference
Compute the SOC chunk address for a feed update at (owner, topic, index)keccak256(identifier || owner). Use this with FileApi::download_chunk to verify retrievability of past updates.
hash_collection_entries
Offline content-address every entry in a collection and assemble them into a Mantaray manifest. Returns the manifest’s root chunk address — the same value Bee would emit on upload_collection_entries. No I/O.
hash_directory
Same as hash_collection_entries but reads entries off disk from the directory tree at dir. Mirrors bee-js hashDirectory.
make_feed_identifier
Compute the feed identifier for a (topic, index) pair — keccak256(topic || BE-uint64(index)).
read_directory_entries
Walk dir recursively, collecting every regular file as a CollectionEntry with its filesystem-relative path. Mirrors bee-go’s filepath.Walk in UploadCollection.
soc_address
Reference to a SOC chunk: keccak256(identifier || owner). Re-exported convenience wrapper over the swarm-level helper.

Type Aliases§

OnStreamProgressFn
Boxed callback for StreamProgress events.