Webhooks for Rust applications
| Tier | data |
| Role | unclassified (baselined) |
| Path | crates/data/webhooks |
| Edition | 2021 |
| Targets | data_webhooks |
| Public items | 51 across 0 modules |
| Tests | 37 |
What it is for
Webhook library crates for Rust applications.
Provides inbound and outbound webhook handling with signature verification and retry logic.
Capabilities
DeliveryStatus
Webhook library crates for Rust applications.
| Item |
|---|
pub enum DeliveryStatus |
DeliveryStatus :: fn is_terminal(& self) -> bool |
EventType
Webhook library crates for Rust applications.
| Item |
|---|
pub struct EventType |
EventType :: fn new(name : impl Into <String>) -> Self |
EventType :: fn wildcard() -> Self |
EventType :: fn matches(& self, other : & EventType) -> bool |
EventType :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
InboundWebhook
Webhook library crates for Rust applications.
| Item |
|---|
pub struct InboundWebhook |
InboundWebhook :: fn new(source : impl Into <String>, path : impl Into <String>) -> Self |
InboundWebhook :: fn with_secret(mut self, secret : impl Into <String>) -> Self |
InboundWebhook :: fn with_metadata(mut self, key : impl Into <String>, value : impl Into <String>) -> Self |
Result
Webhook library crates for Rust applications.
| Item |
|---|
pub type Result<T>: std::result::Result <T, WebhookError> |
SignatureAlgorithm
Webhook library crates for Rust applications.
| Item |
|---|
pub enum SignatureAlgorithm |
SignatureAlgorithm :: fn header_name(& self) -> & 'static str |
WebhookConfig
Webhook library crates for Rust applications.
| Item |
|---|
pub struct WebhookConfig |
WebhookConfig :: fn default() -> Self |
WebhookDelivery
Webhook library crates for Rust applications.
| Item |
|---|
pub struct WebhookDelivery |
WebhookDelivery :: fn new(endpoint_id : Uuid, event : WebhookEvent) -> Self |
WebhookDelivery :: fn with_max_attempts(mut self, max : u32) -> Self |
WebhookDelivery :: fn mark_delivered(& mut self, status : u16, body : Option <String>) |
WebhookDelivery :: fn mark_failed(& mut self, error : impl Into <String>, status : Option <u16>) |
WebhookDelivery :: fn should_retry(& self) -> bool |
WebhookDelivery :: fn retries_exhausted(& self) -> bool |
WebhookDirection
Webhook library crates for Rust applications.
| Item |
|---|
pub enum WebhookDirection |
WebhookEndpoint
Webhook library crates for Rust applications.
| Item |
|---|
pub struct WebhookEndpoint |
WebhookEndpoint :: fn new(url : impl Into <String>, secret : impl Into <String>) -> Self |
WebhookEndpoint :: fn with_events(mut self, events : Vec <EventType>) -> Self |
WebhookEndpoint :: fn with_event(mut self, event : EventType) -> Self |
WebhookEndpoint :: fn with_description(mut self, description : impl Into <String>) -> Self |
WebhookEndpoint :: fn with_metadata(mut self, key : impl Into <String>, value : impl Into <String>) -> Self |
WebhookEndpoint :: fn set_enabled(& mut self, enabled : bool) |
WebhookEndpoint :: fn should_receive(& self, event_type : & EventType) -> bool |
WebhookEndpoint :: fn rotate_secret(& mut self, new_secret : impl Into <String>) |
WebhookError
Webhook library crates for Rust applications.
| Item |
|---|
pub enum WebhookError |
WebhookEvent
Webhook library crates for Rust applications.
| Item |
|---|
pub struct WebhookEvent |
WebhookEvent :: fn new <T : Serialize>(event_type : impl Into <String>, payload : & T) -> Result <Self> |
WebhookEvent :: fn from_value(event_type : impl Into <String>, payload : serde_json::Value) -> Self |
WebhookHandler
Webhook library crates for Rust applications.
| Item |
|---|
pub trait WebhookHandler |
WebhookLog
Webhook library crates for Rust applications.
| Item |
|---|
pub struct WebhookLog |
WebhookLog :: fn outbound(webhook_id : Uuid, event_type : EventType, url : impl Into <String>, body : impl Into <String>,) -> Self |
WebhookLog :: fn inbound(webhook_id : Uuid, event_type : EventType, url : impl Into <String>, body : impl Into <String>,) -> Self |
WebhookLog :: fn record_success(mut self, status : u16, headers : HashMap <String, String>, body : String, duration_ms : u64,) -> Self |
WebhookLog :: fn record_failure(mut self, error : impl Into <String>, duration_ms : Option <u64>) -> Self |
WebhookLog :: fn with_request_headers(mut self, headers : HashMap <String, String>) -> Self |
WebhookSignature
Webhook library crates for Rust applications.
| Item |
|---|
pub struct WebhookSignature |
WebhookSignature :: fn new(timestamp : i64, signature : impl Into <String>, algorithm : SignatureAlgorithm,) -> Self |
WebhookSignature :: fn from_header(header : & str) -> Option <Self> |
WebhookSignature :: fn sign(secret : & u8, timestamp : i64, body : & u8, algorithm : SignatureAlgorithm) -> Self |
WebhookSignature :: fn verify(& self, secret : & u8, body : & u8, tolerance_seconds : i64) -> Result <()> |
WebhookSignature :: fn is_expired(& self, tolerance_seconds : i64) -> bool |
WebhookSignature :: fn to_header(& self) -> String |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub enum WebhookError | Webhook errors. |
pub type Result<T>: std::result::Result <T, WebhookError> | Result type for webhook operations. |
pub struct EventType | Webhook event types. |
EventType :: fn new(name : impl Into <String>) -> Self | Create a new event type. |
EventType :: fn wildcard() -> Self | Create a wildcard event type that matches all events. |
EventType :: fn matches(& self, other : & EventType) -> bool | Check if this event type matches another. |
EventType :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum DeliveryStatus | Webhook delivery status. |
DeliveryStatus :: fn is_terminal(& self) -> bool | Check if this is a terminal status. |
pub struct WebhookEndpoint | Webhook endpoint configuration. |
WebhookEndpoint :: fn new(url : impl Into <String>, secret : impl Into <String>) -> Self | Create a new webhook endpoint. |
WebhookEndpoint :: fn with_events(mut self, events : Vec <EventType>) -> Self | Subscribe to specific events. |
WebhookEndpoint :: fn with_event(mut self, event : EventType) -> Self | Add a single event subscription. |
WebhookEndpoint :: fn with_description(mut self, description : impl Into <String>) -> Self | Set description. |
WebhookEndpoint :: fn with_metadata(mut self, key : impl Into <String>, value : impl Into <String>) -> Self | Add metadata. |
WebhookEndpoint :: fn set_enabled(& mut self, enabled : bool) | Enable or disable the endpoint. |
WebhookEndpoint :: fn should_receive(& self, event_type : & EventType) -> bool | Check if the endpoint should receive an event. |
WebhookEndpoint :: fn rotate_secret(& mut self, new_secret : impl Into <String>) | Update the secret. |
pub struct WebhookEvent | Webhook event payload. |
WebhookEvent :: fn new <T : Serialize>(event_type : impl Into <String>, payload : & T) -> Result <Self> | Create a new webhook event. |
WebhookEvent :: fn from_value(event_type : impl Into <String>, payload : serde_json::Value) -> Self | Create from a JSON value directly. |
pub struct WebhookDelivery | Webhook delivery attempt. |
WebhookDelivery :: fn new(endpoint_id : Uuid, event : WebhookEvent) -> Self | Create a new delivery. |
WebhookDelivery :: fn with_max_attempts(mut self, max : u32) -> Self | Set maximum attempts. |
WebhookDelivery :: fn mark_delivered(& mut self, status : u16, body : Option <String>) | Record a successful delivery. |
WebhookDelivery :: fn mark_failed(& mut self, error : impl Into <String>, status : Option <u16>) | Record a failed delivery attempt. |
WebhookDelivery :: fn should_retry(& self) -> bool | Check if the delivery should be retried. |
WebhookDelivery :: fn retries_exhausted(& self) -> bool | Check if all retries are exhausted. |
pub enum SignatureAlgorithm | Signature algorithm for webhook verification. |
SignatureAlgorithm :: fn header_name(& self) -> & 'static str | Get the header name for this algorithm. |
pub struct WebhookSignature | Webhook signature for verification. |
WebhookSignature :: fn new(timestamp : i64, signature : impl Into <String>, algorithm : SignatureAlgorithm,) -> Self | Create a new signature. |
WebhookSignature :: fn from_header(header : & str) -> Option <Self> | Parse a signature from a header value. |
WebhookSignature :: fn sign(secret : & u8, timestamp : i64, body : & u8, algorithm : SignatureAlgorithm) -> Self | Compute an HMAC signature over the raw body bytes, scoped to timestamp |
WebhookSignature :: fn verify(& self, secret : & u8, body : & u8, tolerance_seconds : i64) -> Result <()> | Verify this signature against secret and the raw inbound body bytes |
WebhookSignature :: fn is_expired(& self, tolerance_seconds : i64) -> bool | Check if the signature has expired. |
WebhookSignature :: fn to_header(& self) -> String | Format as a header value. |
pub struct WebhookConfig | Configuration for webhook delivery. |
WebhookConfig :: fn default() -> Self | — |
pub trait WebhookHandler | Trait for webhook handlers. |
pub struct InboundWebhook | Inbound webhook for receiving webhooks from external services. |
InboundWebhook :: fn new(source : impl Into <String>, path : impl Into <String>) -> Self | Create a new inbound webhook. |
InboundWebhook :: fn with_secret(mut self, secret : impl Into <String>) -> Self | Set the secret for signature verification. |
InboundWebhook :: fn with_metadata(mut self, key : impl Into <String>, value : impl Into <String>) -> Self | Add metadata. |
pub struct WebhookLog | Webhook delivery log entry. |
pub enum WebhookDirection | Direction of webhook (inbound or outbound). |
WebhookLog :: fn outbound(webhook_id : Uuid, event_type : EventType, url : impl Into <String>, body : impl Into <String>,) -> Self | Create a new outbound webhook log. |
WebhookLog :: fn inbound(webhook_id : Uuid, event_type : EventType, url : impl Into <String>, body : impl Into <String>,) -> Self | Create a new inbound webhook log. |
WebhookLog :: fn record_success(mut self, status : u16, headers : HashMap <String, String>, body : String, duration_ms : u64,) -> Self | Record a successful response. |
WebhookLog :: fn record_failure(mut self, error : impl Into <String>, duration_ms : Option <u64>) -> Self | Record a failed response. |
WebhookLog :: fn with_request_headers(mut self, headers : HashMap <String, String>) -> Self | Add request headers. |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier data with 2 other crates: data-export, data-import.
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | data |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/data/webhooks |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
chrono | ^0.4 | serde | no | always |
hex | ^0.4 | — | no | always |
hmac | ^0.12 | — | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sha2 | ^0.10 | — | no | always |
subtle | ^2 | — | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_webhooks["application-webhooks"] -->|uses| SELF SELF["data-webhooks"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | data_webhooks | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
WebhookError | Result |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
1 workspace crate depends on this one: application-webhooks.
Verification
| Kind | Count |
|---|---|
| Unit tests | 37 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 14 | 0 | 1 |
What the tests establish, by name:
test_delivery_status_is_terminal—src/lib.rstest_event_type_display—src/lib.rstest_event_type_matches_exact—src/lib.rstest_event_type_matches_prefix—src/lib.rstest_event_type_matches_wildcard—src/lib.rstest_event_type_no_match—src/lib.rstest_inbound_webhook_creation—src/lib.rstest_signature_algorithm_header_name—src/lib.rstest_webhook_config_defaults—src/lib.rstest_webhook_delivery_creation—src/lib.rstest_webhook_delivery_mark_delivered—src/lib.rstest_webhook_delivery_mark_failed_exhausted—src/lib.rstest_webhook_delivery_mark_failed_with_retry—src/lib.rstest_webhook_delivery_should_retry—src/lib.rstest_webhook_endpoint_creation—src/lib.rstest_webhook_endpoint_disabled—src/lib.rstest_webhook_endpoint_events—src/lib.rstest_webhook_endpoint_rotate_secret—src/lib.rstest_webhook_endpoint_should_receive—src/lib.rstest_webhook_event_creation—src/lib.rstest_webhook_event_from_value—src/lib.rstest_webhook_log_inbound—src/lib.rstest_webhook_log_outbound—src/lib.rstest_webhook_log_record_failure—src/lib.rstest_webhook_log_record_success—src/lib.rstest_webhook_sign_header_roundtrip_verifies—src/lib.rstest_webhook_sign_then_verify_roundtrip_sha256—src/lib.rstest_webhook_sign_then_verify_roundtrip_sha512—src/lib.rstest_webhook_signature_expired—src/lib.rstest_webhook_signature_from_header—src/lib.rs- _… 7 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 49 | 51 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 49
"No rustdoc detected" : 2
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 1043 |
| Code lines | 823 |
| Public API items | 51 |
| Public modules | 0 |
| Tests | 37 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 10 |
| Workspace reverse dependencies | 1 |
pie showData
title Public API by kind
"enum" : 4
"method" : 37
"struct" : 8
"trait" : 1
"type alias" : 1
pie showData
title Rust source composition
"Code" : 823
"Blank or comment" : 220
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.