#[repr(C)]pub struct HurrayTransport {
pub ctx: *mut c_void,
pub read: HurrayTransportReadFn,
pub write: HurrayTransportWriteFn,
pub release: HurrayTransportReleaseFn,
pub read_at: HurrayTransportReadAtFn,
pub size: HurrayTransportSizeFn,
}Expand description
A caller-supplied byte transport: a context pointer plus the callbacks that move bytes.
Not a path and not a file descriptor. A vtable composes with a socket, a pipe, a memory span, or the caller’s own object, and file descriptors are a portability wart of their own.
The struct is copied on construction, so the caller MAY free the HurrayTransport
itself as soon as the handle is created; ctx must outlive the handle, and is released
through release when the handle is destroyed.
Thread affinity: one handle, one thread at a time. Hurray runs no threads of its own, so this is a rule rather than a threading model.
Fields§
§ctx: *mut c_voidOpaque caller context, passed verbatim to every callback. MAY be null.
read: HurrayTransportReadFnRequired by a reader; MAY be null for a write-only transport.
write: HurrayTransportWriteFnRequired by a writer; MAY be null for a read-only transport.
release: HurrayTransportReleaseFnInvoked once when the owning handle is destroyed. MAY be null.
read_at: HurrayTransportReadAtFnRequired by a file reader; MAY be null for a stream or write-only transport.
size: HurrayTransportSizeFnRequired by a file reader; MAY be null for a stream or write-only transport.