Expand description
This is the Rust client for Hook0. It makes it easier to send events from a Rust application to a Hook0 instance.
§Sending an event is idempotent, and retried
Hook0Client::send_event sends every event under an ID it knows: the one set on the
Event, or a UUIDv7 it generates when the event carries none. Passing no ID no longer means
the ID comes from Hook0 — the interface is unchanged, but the value now comes from the client,
is sent with the request and is what send_event returns.
That is what makes retrying safe. Hook0 keys events on their ID, so a request that is repeated after a network failure or a server error ingests the event once rather than twice; without a client-chosen ID, a repeated request would create a second event and deliver it to every subscriber.
Every send is bounded, and every bound is configurable:
Hook0Client::with_max_payload_bytes rules an oversized payload out before anything is sent,
Hook0Client::with_request_timeout bounds one attempt,
Hook0Client::with_max_response_bytes bounds what an answer may cost to read, and
RetryPolicy bounds how many attempts are made and how long they may spend waiting between
them. Pass RetryPolicy::disabled to send each event exactly once.
Modules§
- generated
- Everything the API document describes, written by the SDK generator and never by hand.
Structs§
- Event
- An event that can be sent to Hook0
- Hook0
Client - The Hook0 client
- Retry
Policy - How a client spaces out the attempts of a single send.
Enums§
- Hook0
Client Error - Every error Hook0 client can encounter
Constants§
- DEFAULT_
MAX_ PAYLOAD_ BYTES - Largest event payload the client agrees to send, unless it is told otherwise with
Hook0Client::with_max_payload_bytes. - DEFAULT_
MAX_ RESPONSE_ BYTES - Largest answer the client reads off the socket, unless it is told otherwise with
Hook0Client::with_max_response_bytes. - DEFAULT_
REQUEST_ TIMEOUT - Longest one attempt at reaching Hook0 is given before it is abandoned, unless the client is
told otherwise with
Hook0Client::with_request_timeout. - MAX_
ATTEMPTS_ CAP - Most attempts a
RetryPolicycan ever make, whatevermax_attemptssays. - MAX_
HEADER_ BYTES - Longest one header line may be, its name and its value together, in bytes.
- MAX_
HEAD_ BYTES - Largest whole head an answer may carry, every line counted together, in bytes.
- MAX_
RESPONSE_ HEADERS - Header lines an answer may carry before this client refuses to read it.
Functions§
- verify_
webhook_ signature - Verifies the signature of a webhook
- verify_
webhook_ signature_ with_ current_ time - Verifies the signature of a webhook