Expand description
File transfer subsystem for truffle-core.
Provides a first-class API for sending and receiving files between peers
in the truffle mesh. The FileTransfer manager handles:
- Sending: Push a local file to a remote peer.
- Receiving: Accept/reject incoming file offers via an offer channel.
- Pulling: Request a file from a remote peer.
- Events: Subscribe to transfer lifecycle events (progress, completed, failed).
§Architecture
The file transfer module sits on top of the Node API, using:
- WS namespace
"ft"for signaling (offers, accepts, rejects, pull requests) - Raw TCP streams for bulk data transfer
- SHA-256 for integrity verification
§Example
ⓘ
let ft = node.file_transfer();
// Subscribe to events
let mut events = ft.subscribe();
// Send a file
let result = ft.send_file("peer-id", "/path/to/file.txt", "file.txt").await?;
// Receive with manual accept/reject
let mut offers = ft.offer_channel().await;
while let Some((offer, responder)) = offers.recv().await {
responder.accept("/tmp/received-file.txt");
}Re-exports§
pub use types::*;
Modules§
- receiver
- Receive handler — background task that handles incoming file transfer requests from other peers.
- sender
- Send (push) — send a local file to a remote peer.
- types
- Types for the file transfer protocol.
Structs§
- File
Transfer - File transfer handle — the public API for file transfers.