asterisk-rs-core
Shared foundation for the asterisk-rs ecosystem. The AMI, AGI, and ARI crates all depend on this crate for common types; it contains no protocol-specific logic.
What it provides
Errors
Error— top-level error enum covering all failure modesConnectionError— TCP connect failures, TLS errors, socket closedAuthError— login rejected, missing credentials, challenge failuresTimeoutError— read/write/login timeoutsProtocolError— malformed frames, unexpected packet structure
Event bus
Event— marker trait required by the bus:Clone + Send + Sync + Debug + 'staticEventBus<E>— broadcast hub; protocol crates publish into it internallyEventSubscription<E>— unbounded receiver; all events since subscribeFilteredSubscription<E>— likeEventSubscriptionbut with a predicate applied before delivery
Reconnection
ReconnectPolicy— three modes:ReconnectPolicy::exponential(initial, max)— doubles delay each attempt, jitter applied to prevent thundering herd (default)ReconnectPolicy::fixed(interval)— constant retry delayReconnectPolicy::none()— fail on first disconnect
ConnectionState— observable state machine:Disconnected → Connecting → Connected → Reconnecting
Credentials
Credentials— username/secret pair;Debugimpl redacts the secret so it never appears in logs or panic output
Domain constants
Strongly-typed enums parsed from Asterisk protocol strings:
| Type | Examples |
|---|---|
HangupCause |
Normal, Busy, NoAnswer, Congestion, NoRouteDestination, … |
ChannelState |
Down, Rsrvd, OffHook, Dialing, Ring, Up, … |
DeviceState |
Unknown, NotInUse, InUse, Busy, Unavailable, … |
DialStatus |
Answer, Busy, NoAnswer, Cancel, Congestion, … |
CdrDisposition |
Answered, NoAnswer, Busy, Failed |
PeerStatus |
Registered, Unregistered, Reachable, Unreachable, … |
QueueStrategy |
RingAll, LeastRecent, FewestCalls, RoundRobin, … |
ExtensionState |
NotInUse, InUse, Busy, Unavailable, … |
AgiStatus |
Success, Failure, NotPermitted |
Usage
You do not need to add this crate as a direct dependency unless you are building
a custom protocol integration. Add asterisk-rs-ami, asterisk-rs-agi, or
asterisk-rs-ari instead; they re-export the types callers need.
Part of asterisk-rs. MSRV 1.83. MIT OR Apache-2.0.