HayateSender is the primary high-level interface for sending files and directories over an encrypted QUIC connection. It follows a builder pattern: configure the sender with chained method calls, then call .send() to establish the connection, perform the cryptographic handshake, and stream the payload. The builder handles both Direct Mode (connect to a known IP address) and Pairing Mode (discover the receiver on the LAN using a shared passphrase) with the same API surface.
Builder Methods
HayateSender
Creates a new
HayateSender with default configuration. Defaults: compression enabled, hash algorithm "blake3". Neither a target address nor a pairing code is set — you must call .target() or .code() before calling .send().HayateSender
Sets the receiver’s socket address for Direct Mode. The sender will initiate a QUIC connection directly to this address. Calling
.target() clears any previously set .code() — the two modes are mutually exclusive.HayateSender
Sets the shared passphrase for Pairing Mode. The sender will broadcast its availability over the local subnet (via mDNS and UDP broadcast) so the receiver can locate and connect to it automatically. The passphrase is also mixed into the HKDF key derivation, so peers that do not know it cannot authenticate the session. Calling
.code() clears any previously set .target().HayateSender
Enables or disables Zstd compression for the transfer payload. Default:
true. Compression reduces network bytes at the cost of CPU time; disable it when sending already-compressed formats (e.g., JPEG, MP4, ZIP).HayateSender
Sets the integrity algorithm used to checksum the transferred payload. Accepted values:
"blake3" (default) or "sha256". The chosen algorithm is transmitted in the encrypted metadata frame so the receiver can verify the same digest independently.Sending
path— accepts anything that implementsAsRef<Path>. Works for both individual files and entire directories; Hayate detects the type automatically and wraps directories in a streaming tar archive.progress_cb— called periodically with the total number of bytes written to the network so far. ReturnOk(())to continue the transfer. ReturnErr(EngineError::Cancelled(...))to abort immediately.
Low-Level Methods
These methods are available for advanced callers who manage their own QUIC connection and want fine-grained control over each transfer stage. They were made public in v6.0.0.Metadata struct and estimates the total byte size for path without opening any network connection. Useful when you want to display transfer details to the user before committing to a connection.
Complete Examples
.target() and .code() are mutually exclusive — the last one you call wins and clears the other. If you call .target() followed by .code(), the sender will use Pairing Mode. If you call .code() followed by .target(), it will use Direct Mode.