Skip to main content

uqa_client/
notifications.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Bounded notification protocol values and incremental decoding. Transport establishment, listener authority and reconnection remain separate owners; decoding a ready frame does not establish those server-side facts.
8
9mod decoder;
10mod framing;
11pub(crate) mod http;
12mod json;
13mod request;
14mod timing;
15mod wire;
16
17pub use decoder::{DecodeStep, NotificationDecoder};
18pub use http::{
19    HttpNotificationError, HttpNotificationOptions, HttpNotificationSubscription,
20    NotificationCancellation, NotificationRetryOptions, NotificationTimeoutStage,
21};
22pub use request::SubscriptionRequest;
23pub use timing::{NotificationTiming, TimerLimits};
24pub use wire::{NotificationReady, NotificationWireEvent, ServerFailure};
25
26/// Complete request body and complete SSE frame limit, including event fields and delimiters.
27pub const MAX_NOTIFICATION_WIRE_BYTES: usize = 65_536;
28
29/// Content-free protocol failures. Rejected input and JSON diagnostic strings are never retained.
30#[derive(Clone, Copy, Debug, PartialEq, Eq, thiserror::Error)]
31pub enum ProtocolError {
32    #[error("notification protocol input exceeds its byte limit")]
33    ByteLimit,
34    #[error("notification protocol input is not valid UTF-8")]
35    InvalidUTF8,
36    #[error("notification protocol JSON is invalid or exceeds its nesting envelope")]
37    InvalidJSON,
38    #[error("notification protocol fields are invalid")]
39    InvalidFields,
40    #[error("notification protocol version is unsupported")]
41    UnsupportedVersion,
42    #[error("notification channel selection is invalid")]
43    InvalidChannels,
44    #[error("notification channel count exceeds its configured limit")]
45    ChannelLimit,
46    #[error("notification protocol does not support resumption")]
47    ResumeUnsupported,
48    #[error("notification response identity is invalid or changed")]
49    Identity,
50    #[error("notification event order is invalid")]
51    EventOrder,
52    #[error("notification sequence is invalid")]
53    Sequence,
54    #[error("notification payload exceeds its byte limit")]
55    Payload,
56    #[error("notification timing relationship is invalid")]
57    Timing,
58    #[error("notification timing exceeds the receiving runtime or local deadline")]
59    TimerRange,
60    #[error("notification protocol allocation failed")]
61    Allocation,
62    #[error("notification stream ended without a complete terminal frame")]
63    UnexpectedEnd,
64}
65
66#[cfg(test)]
67mod tests;