Expand description
File-transfer protocol helpers for thincan.
This crate provides Cap’n Proto message types and helpers for building a simple file transfer
protocol on top of thincan.
§Integration steps
- Define
FileReq/FileChunk/FileAckin your bus atlas usingschemaowned types. - Implement
Atlasfor your atlas marker type. - Include
FileTransferBundlein athincan::maplet!bundle list. - Build
maplet::Bundles::new(&iface)and call methods on the singleton bundle instance:- sender:
bundles.file_transfer.send_file(...)/send_file_with_id(...) - receiver (
alloc):bundles.file_transfer.recv_file(...) - receiver (
heapless):bundles.file_transfer.recv_file_no_alloc(...)
- sender:
§Backpressure / throttling
Sender flow is ack-driven and windowed. Receiver flow only sends progress/completion acks after storage writes complete, so slow storage naturally throttles transfer rate.
§Runtime note
These methods rely on your external demux pump to feed incoming frames into the bus mailbox
via BusHandle::ingest.
With --features heapless you can encode Cap’n Proto bodies without allocation:
ⓘ
let used = ft::encode_file_ack_into(
&mut scratch,
transfer_id,
kind,
next_offset,
chunk_size,
error,
&mut out,
)?;
// Send `&out[..used]` as the body of your bus's `FileAck` message.This crate is async-first and is designed for runtimes like embassy where storage I/O must not block the executor.
Re-exports§
pub use file_transfer_capnp as schema;
Modules§
Structs§
- File
AckValue - Value type used to encode a
FileAckmessage. - File
Chunk Value - Value type used to encode a
FileChunkmessage for a specific atlas marker typeA. - File
Offer Value - Value type used to encode a
FileReqmessage including metadata and chunk negotiation. - File
ReqValue - Value type used to encode a
FileReqmessage for a specific atlas marker typeA. - File
Transfer Bundle - Bundle type for file-transfer protocol operations.
- Pending
Ack - Ack message that the receiver side would like to emit.
- Receiver
Config - Receiver-side configuration.
Enums§
- Error
- Errors produced by the file-transfer state machine.
Constants§
- DEFAULT_
CHUNK_ SIZE - Default chunk size (bytes) used by senders.
- FILE_
TRANSFER_ MESSAGE_ COUNT - Number of message types required by
FileTransferBundle.
Traits§
- Async
File Store - Async dependency required by the file-transfer bundle: a byte-addressable file store.
- Atlas
- Atlas contract for file-transfer message types.
Functions§
- capnp_
padded_ len - Cap’n Proto “word padding” (Cap’n Proto Data blobs are padded to a word boundary).
- capnp_
scratch_ words_ for_ bytes - Convert a byte count to a conservative Cap’n Proto scratch requirement (words).
- file_
ack_ accept - file_
ack_ max_ encoded_ len - Upper bound for an encoded
FileAckbody (bytes). - file_
ack_ progress - file_
ack_ reject - file_
chunk - Convenience constructor for
FileChunkValue. - file_
chunk_ max_ encoded_ len - Upper bound for an encoded
FileChunkbody (bytes). - file_
offer - Convenience constructor for
FileOfferValue. - file_
offer_ max_ encoded_ len - Upper bound for an encoded
FileReqbody (bytes) with metadata. - file_
req - Convenience constructor for
FileReqValue. - file_
req_ max_ encoded_ len - Upper bound for an encoded
FileReqbody (bytes) without metadata.