RNS::Resource
Handles large data transfers over Link instances using segmentation,
sliding-window flow control, and adaptive rate adjustment. Data is split
into parts, each verified by a map hash, and transmitted with automatic
retry and congestion back-off. Supports compression, encryption, metadata,
and multi-segment transfers for payloads that exceed a single advertisement.
Constants
Flags indicating whether all hashmap segments have been delivered. ─── Hashmap flags ─────────────────────────────────────────────
Size limits governing part hashing, maximum transfer sizes, and the automatic compression threshold. ─── Size constants ────────────────────────────────────────────
Timeout multipliers, retry budgets, and grace periods that govern how long to wait for parts/proofs before retransmitting or failing. ─── Timeout and retry constants ───────────────────────────────
Throughput thresholds (bytes/sec) used to classify the link speed and select the appropriate window ceiling. ─── Rate constants ────────────────────────────────────────────
Transfer lifecycle states. Values are ordered so that status < COMPLETE
means the transfer is still in progress.
─── Status constants ──────────────────────────────────────────
Window parameters controlling how many unacknowledged parts may be
in flight. The window grows or shrinks based on measured throughput
(see FAST_RATE_THRESHOLD / VERY_SLOW_RATE_THRESHOLD).
─── Window constants ──────────────────────────────────────────
Constructors
─── Sender constructor ──────────────────────────────────────── Creates a sender-side resource. The data is optionally compressed, split into SDU-sized parts with map hashes, and (when advertise is true) immediately advertised to the remote peer.
Class methods
Accepts an incoming resource advertisement and constructs a receiver-side
Resource. Initialises the hashmap, starts the watchdog fiber, and
returns the new resource (or nil if the link is unavailable or a
transfer for the same hash is already in progress).
Declines an incoming resource advertisement by sending a RESOURCE_RCL
packet back to the advertising peer. The resource is never allocated.
Instance methods
Spawns a fiber that sends the ResourceAdvertisement for this resource
over its link. If the resource has multiple segments, a second fiber
begins preparing the next segment in parallel.
Aborts the transfer if it has not already completed. Sends a
RESOURCE_ICL cancel packet when this side is the initiator,
deregisters the resource from the link, and invokes the callback.
Generates an UInt64 hash value for this object.
This method must have the property that a == b implies a.hash == b.hash.
The hash value is used along with == by the Hash class to determine if two objects
reference the same hash key.
Subclasses must not override this method. Instead, they must define hash(hasher),
though usually the macro def_hash can be used to generate this method.
Hashmap (sender: concatenated bytes, receiver: array of Bytes?)
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>