Skip to main content

rings_core/error/
kind.rs

1use super::CallbackError;
2
3/// Errors collections in ring-core.
4#[derive(thiserror::Error, Debug)]
5#[non_exhaustive]
6pub enum Error {
7    /// Serialize affine failed
8    #[error("Serialize affine failed")]
9    EccSerializeFailed,
10    /// desrialize affine failed
11    #[error("desrialize affine failed")]
12    EccDeserializeFailed,
13    /// Failed to initialize Curve hasher
14    #[error("Failed to initialize Curve hasher")]
15    CurveHasherInitFailed,
16    /// Failed to hash data into cruve
17    #[error("Failed to hash data into cruve")]
18    CurveHasherFailed,
19
20    /// Ed25519/EdDSA pubkey bad format
21    #[error("Ed25519/EdDSA pubkey bad format")]
22    EdDSAPublicKeyBadFormat,
23
24    /// Secp256k1/ECDSA pubkey bad format
25    #[error("Secp256k1/ECDSA pubkey bad format")]
26    ECDSAPublicKeyBadFormat,
27
28    /// Failed to lift encoded plaintext into a secp256k1 point
29    #[error("Failed to lift encoded plaintext into a secp256k1 point")]
30    Secp256k1PointLiftFailed,
31
32    /// E2E stream id mismatch: expected {expected}, actual {actual}
33    #[error("E2E stream id mismatch: expected {expected}, actual {actual}")]
34    E2eStreamIdMismatch {
35        /// Stream ID expected by the decryptor.
36        expected: uuid::Uuid,
37        /// Stream ID carried by the frame.
38        actual: uuid::Uuid,
39    },
40
41    /// E2E frame sequence mismatch: expected {expected}, actual {actual}
42    #[error("E2E frame sequence mismatch: expected {expected}, actual {actual}")]
43    E2eFrameSequenceMismatch {
44        /// Sequence number expected by the decryptor.
45        expected: u64,
46        /// Sequence number carried by the frame.
47        actual: u64,
48    },
49
50    /// E2E frame sequence is outside the accepted reorder window.
51    #[error(
52        "E2E frame sequence {actual} exceeds reorder window {window} from next sequence {next_sequence}"
53    )]
54    E2eFrameReorderWindowExceeded {
55        /// Next contiguous sequence number expected by the decryptor.
56        next_sequence: u64,
57        /// Sequence number carried by the frame.
58        actual: u64,
59        /// Maximum accepted gap ahead of the next sequence.
60        window: u64,
61    },
62
63    /// E2E frame sequence counter overflowed
64    #[error("E2E frame sequence counter overflowed")]
65    E2eFrameSequenceOverflow,
66
67    /// E2E frame received after the authenticated final frame
68    #[error("E2E frame received after the authenticated final frame")]
69    E2eFrameAfterFinal,
70
71    /// E2E stream is missing the authenticated final frame
72    #[error("E2E stream is missing the authenticated final frame")]
73    E2eMissingFinalFrame,
74
75    /// E2E public key resolves to {actual}, expected {expected}
76    #[error("E2E public key resolves to {actual}, expected {expected}")]
77    E2ePublicKeyDidMismatch {
78        /// DID expected by the signed message context.
79        expected: crate::dht::Did,
80        /// DID derived from the supplied public key.
81        actual: crate::dht::Did,
82    },
83
84    /// Secp256r1/ECDSA Error: {0}
85    #[error("Secp256r1/ECDSA Error: {0}")]
86    ECDSAError(#[from] ecdsa::Error),
87
88    /// ECDSA or EdDSA pubkey bad format
89    #[error("ECDSA or EdDSA pubkey bad format")]
90    PublicKeyBadFormat,
91
92    /// Failed to decode vector to bls affine
93    #[error("Failed to decode vector to bls affine")]
94    BlsAffineDecodeFailed,
95
96    /// private bad format
97    #[error("private bad format")]
98    PrivateKeyBadFormat,
99
100    /// Invalid Transport
101    #[error("Invalid Transport")]
102    InvalidTransport,
103
104    /// InvalidPublicKey
105    #[error("InvalidPublicKey")]
106    InvalidPublicKey,
107
108    /// Entry kind not equal when overwriting
109    #[error("Entry kind not equal when overwriting")]
110    EntryKindNotEqual,
111
112    /// Did of Entry not equal
113    #[error("Did of Entry not equal")]
114    EntryDidNotEqual,
115
116    /// The type of Entry is not allowed to be overwritten
117    #[error("The type of Entry is not allowed to be overwritten")]
118    EntryNotOverwritable,
119
120    /// The type of Entry is not allowed to be appended
121    #[error("The type of Entry is not allowed to be appended")]
122    EntryNotAppendable,
123
124    /// Entry dot index {index} is out of bounds
125    #[error("Entry dot index {index} is out of bounds")]
126    EntryDotIndexOutOfBounds {
127        /// Dot index that could not be represented.
128        index: usize,
129    },
130
131    /// Affine rotation scalar must be greater than zero
132    #[error("Affine rotation scalar must be greater than zero")]
133    InvalidAffineScalar,
134
135    /// Storage redundancy mismatch: transport configured {configured}, storage request uses {requested}
136    #[error("Storage redundancy mismatch: transport configured {configured}, storage request uses {requested}")]
137    StorageRedundancyMismatch {
138        /// Redundancy configured on swarm transport for repair.
139        configured: u16,
140        /// Redundancy requested by the storage API const generic.
141        requested: u16,
142    },
143
144    /// Encode a byte vector into a base58-check string, adds 4 bytes checksum
145    #[error("Encode a byte vector into a base58-check string, adds 4 bytes checksum")]
146    Encode,
147
148    /// Decode base58-encoded with 4 bytes checksum string into a byte vector
149    #[error("Decode base58-encoded with 4 bytes checksum string into a byte vector")]
150    Decode,
151
152    /// Couldn't decode data as UTF-8.
153    #[error("Couldn't decode data as UTF-8.")]
154    Utf8Encoding(#[from] std::string::FromUtf8Error),
155
156    /// IOError
157    #[error("IOError")]
158    ServiceIOError(#[from] std::io::Error),
159
160    /// Invalid hexadecimal id in directory cache
161    #[error("Invalid hexadecimal id in directory cache")]
162    BadHexInCache(#[from] hex::FromHexError),
163
164    /// Invalid rustc hexadecimal id in directory cache
165    #[error("Invalid rustc hexadecimal id in directory cache")]
166    BadCHexInCache,
167
168    /// URL parse error
169    #[error("URL parse error")]
170    URLParse(#[from] url::ParseError),
171
172    /// Invalid hexadecimal id in directory cache
173    #[error("Invalid hexadecimal id in directory cache")]
174    BadArrayInCache(#[from] std::array::TryFromSliceError),
175
176    /// JSON serialize toString error
177    #[error("JSON serialize toString error")]
178    SerializeToString,
179
180    /// Serialization error
181    #[error("Serialization error")]
182    SerializeError,
183
184    /// JSON serialization error
185    #[error("JSON serialization error")]
186    Serialize(#[source] serde_json::Error),
187
188    /// JSON deserialization error
189    #[error("JSON deserialization error")]
190    Deserialize(#[source] serde_json::Error),
191
192    /// Codec serialization error
193    #[error("Codec serialization error")]
194    CodecSerialize(#[source] rings_codec::Error),
195
196    /// Codec deserialization error
197    #[error("Codec deserialization error")]
198    CodecDeserialize(#[source] rings_codec::Error),
199
200    /// Unknown account
201    #[error("Unknown account")]
202    UnknownAccount,
203
204    /// Failed on verify message signature
205    #[error("Failed on verify message signature")]
206    VerifySignatureFailed,
207
208    /// ECDSA Invalid recover Id {0}
209    #[error("ECDSA Invalid recover Id {0}")]
210    InvalidRecoverId(u8),
211
212    /// Gzip encode error.
213    #[error("Gzip encode error.")]
214    GzipEncode,
215
216    /// Gzip decode error.
217    #[error("Gzip decode error.")]
218    GzipDecode,
219
220    /// Failed on promise, state is not succeeded
221    #[error("Failed on promise, state is not succeeded")]
222    PromiseStateFailed,
223
224    /// promise timeout, state is not succeeded
225    #[error("promise timeout, state is not succeeded")]
226    PromiseStateTimeout,
227
228    /// Ice server scheme {0} has not supported yet
229    #[error("Ice server scheme {0} has not supported yet")]
230    IceServerSchemeNotSupport(String),
231
232    /// Ice server get url without host
233    #[error("Ice server get url without host")]
234    IceServerURLMissHost,
235
236    /// Cannot find next node by local DHT
237    #[error("Cannot find next node by local DHT")]
238    MessageHandlerMissNextNode,
239
240    /// Found existing transport when answer offer from remote node
241    #[error("Found existing transport when answer offer from remote node")]
242    AlreadyConnected,
243
244    /// Pending WebRTC connection capacity {capacity} is exhausted
245    #[error("Pending WebRTC connection capacity {capacity} is exhausted")]
246    PendingConnectionCapacityExceeded {
247        /// Maximum number of concurrent pending peers.
248        capacity: usize,
249    },
250
251    /// Pending WebRTC connection generation id space is exhausted.
252    #[error("Pending WebRTC connection generation is exhausted")]
253    PendingConnectionGenerationExhausted,
254
255    /// Connection attempt {generation} for {peer} was replaced before setup completed.
256    #[error("Connection attempt {generation} for {peer} was superseded")]
257    ConnectionAttemptSuperseded {
258        /// Peer whose connection generation changed.
259        peer: crate::dht::Did,
260        /// Generation that no longer owns the peer slot.
261        generation: u64,
262    },
263
264    /// A predecessor notification claims a DID different from its signed origin.
265    #[error("Notify predecessor DID {claimed} does not match relay origin {origin}")]
266    NotifyPredecessorOriginMismatch {
267        /// DID claimed by the notification body.
268        claimed: crate::dht::Did,
269        /// DID authenticated by the signed relay origin.
270        origin: crate::dht::Did,
271    },
272
273    /// A predecessor notification originated from a peer without an admitted connection.
274    #[error("Notify predecessor origin {origin} is not an admitted connection")]
275    NotifyPredecessorOriginNotAdmitted {
276        /// Authenticated origin that has no admitted connection generation.
277        origin: crate::dht::Did,
278    },
279
280    /// Failed to access the swarm connection lifecycle state
281    #[error("Failed to access the swarm connection lifecycle state")]
282    SwarmConnectionLifecycleLock,
283
284    /// You should not connect to yourself
285    #[error("You should not connect to yourself")]
286    ShouldNotConnectSelf,
287
288    /// Send message through channel failed
289    #[error("Send message through channel failed")]
290    ChannelSendMessageFailed,
291
292    /// The per-peer outbound scheduler has admitted its maximum transfer count.
293    #[error("Outbound transfer capacity {capacity} exceeded for peer {peer}")]
294    OutboundTransferCapacityExceeded {
295        /// Peer whose scheduler is at capacity.
296        peer: crate::dht::Did,
297        /// Maximum transfers admitted across all scheduler states.
298        capacity: usize,
299    },
300
301    /// The outbound scheduler cannot retain another payload within its byte budget.
302    #[error(
303        "Outbound transfer of {requested_bytes} bytes exceeds the remaining {capacity_bytes}-byte budget for peer {peer}"
304    )]
305    OutboundTransferMemoryCapacityExceeded {
306        /// Peer whose scheduler would retain the payload.
307        peer: crate::dht::Did,
308        /// Bytes the transfer needs to retain.
309        requested_bytes: usize,
310        /// Total byte capacity of the exhausted budget.
311        capacity_bytes: usize,
312    },
313
314    /// A detached send could not obtain bounded scheduler capacity in time.
315    #[error(
316        "Timed out after {timeout_ms}ms waiting for outbound transfer capacity for peer {peer}"
317    )]
318    OutboundTransferAdmissionTimeout {
319        /// Peer whose scheduler capacity remained exhausted.
320        peer: crate::dht::Did,
321        /// Admission deadline in milliseconds.
322        timeout_ms: u128,
323    },
324
325    /// A detached transfer did not admit its first frame before its deadline.
326    #[error("Timed out after {timeout_ms}ms waiting to admit the first outbound frame for {peer}")]
327    OutboundFirstFrameAdmissionTimeout {
328        /// Peer whose scheduler lane did not admit the first frame.
329        peer: crate::dht::Did,
330        /// First-frame admission deadline in milliseconds.
331        timeout_ms: u128,
332    },
333
334    /// A detached transfer did not stop within its post-deadline cleanup grace.
335    #[error(
336        "Detached payload cleanup for {peer} exceeded its {timeout_ms}ms grace after the first-frame deadline"
337    )]
338    DetachedPayloadCleanupTimeout {
339        /// Peer whose exact connection generation was made send-terminal.
340        peer: crate::dht::Did,
341        /// Cleanup grace in milliseconds.
342        timeout_ms: u128,
343    },
344
345    /// No Tokio runtime is available to host a native outbound scheduler.
346    #[error("Outbound scheduler requires an active Tokio runtime")]
347    OutboundSchedulerRuntimeUnavailable,
348
349    /// A cancelled detached admission unexpectedly published send success.
350    #[error("Cancelled detached outbound admission published success")]
351    CancelledDetachedAdmissionPublishedSuccess,
352
353    /// The inbound actor has admitted its maximum number of messages.
354    #[error("Inbound mailbox capacity {capacity} exceeded")]
355    InboundMailboxCapacityExceeded {
356        /// Maximum queued and executing inbound messages.
357        capacity: usize,
358    },
359
360    /// The inbound actor cannot retain another message within its byte budget.
361    #[error(
362        "Inbound message of {requested_bytes} bytes exceeds the {capacity_bytes}-byte mailbox budget"
363    )]
364    InboundMailboxMemoryCapacityExceeded {
365        /// Bytes retained by the decoded message and its handler representation.
366        requested_bytes: usize,
367        /// Total mailbox byte capacity.
368        capacity_bytes: usize,
369    },
370
371    /// One peer has exhausted its inbound message count allowance.
372    #[error("Inbound peer {peer:?} capacity {capacity} exceeded")]
373    InboundPeerCapacityExceeded {
374        /// Peer associated with the inbound connection, when its DID parsed successfully.
375        peer: Option<crate::dht::Did>,
376        /// Maximum queued and executing messages retained for one peer.
377        capacity: usize,
378    },
379
380    /// One peer has exhausted its inbound retained-memory allowance.
381    #[error(
382        "Inbound peer {peer:?} message of {requested_bytes} bytes exceeds its {capacity_bytes}-byte budget"
383    )]
384    InboundPeerMemoryCapacityExceeded {
385        /// Peer associated with the inbound connection, when its DID parsed successfully.
386        peer: Option<crate::dht::Did>,
387        /// Bytes requested by the inbound message.
388        requested_bytes: usize,
389        /// Retained byte capacity available to one peer.
390        capacity_bytes: usize,
391    },
392
393    /// The connection's inbound mailbox actor is unavailable.
394    #[error("Inbound mailbox is closed")]
395    InboundMailboxClosed,
396
397    /// No Tokio runtime is available to host a native inbound actor.
398    #[error("Inbound mailbox requires an active Tokio runtime")]
399    InboundMailboxRuntimeUnavailable,
400
401    /// The inbound actor observed an impossible message/lane state.
402    #[error("Inbound actor state invariant violated")]
403    InboundActorInvariantViolation,
404
405    /// A reassembled chunk payload attempted to contain another chunk envelope.
406    #[error("Nested chunk messages are not allowed")]
407    NestedChunkMessage,
408
409    /// A chunk was rejected for an invalid remote wire shape or metadata.
410    #[error("Invalid chunk message")]
411    InvalidChunkMessage,
412
413    /// The application rejected an inbound message during validation.
414    #[error("Inbound message validation failed: {source}")]
415    InboundValidationFailed {
416        /// Original application validation error.
417        #[source]
418        source: CallbackError,
419    },
420
421    /// An application validation callback did not complete within its deadline.
422    #[error("Inbound validation for {peer:?} timed out after {timeout_ms}ms")]
423    InboundValidationTimeout {
424        /// Peer associated with the inbound connection, when its DID parsed successfully.
425        peer: Option<crate::dht::Did>,
426        /// Callback deadline in milliseconds.
427        timeout_ms: u128,
428    },
429
430    /// An application callback failed after core inbound handling.
431    #[error("Inbound message callback failed: {source}")]
432    InboundCallbackFailed {
433        /// Original application callback error.
434        #[source]
435        source: CallbackError,
436    },
437
438    /// Inbound handling and its application callback did not complete within the deadline.
439    #[error("Inbound processing for {peer:?} timed out after {timeout_ms}ms")]
440    InboundProcessingTimeout {
441        /// Peer associated with the inbound connection, when its DID parsed successfully.
442        peer: Option<crate::dht::Did>,
443        /// Processing deadline in milliseconds.
444        timeout_ms: u128,
445    },
446
447    /// The browser runtime could not schedule an inbound deadline timer.
448    #[error("Inbound {operation} timer unavailable for {peer:?}")]
449    InboundTimerUnavailable {
450        /// Peer associated with the inbound connection, when its DID parsed successfully.
451        peer: Option<crate::dht::Did>,
452        /// Inbound phase whose deadline could not be scheduled.
453        operation: &'static str,
454    },
455
456    /// Recv message through channel failed {0}
457    #[error("Recv message through channel failed {0}")]
458    ChannelRecvMessageFailed(String),
459
460    /// Invalid PeerRingAction
461    #[error("Invalid PeerRingAction")]
462    PeerRingInvalidAction,
463
464    /// Failed on read successors
465    #[error("Failed on read successors")]
466    FailedToReadSuccessors,
467
468    /// Successor index {index} is out of bounds for length {len}
469    #[error("Successor index {index} is out of bounds for length {len}")]
470    SuccessorIndexOutOfBounds {
471        /// Requested successor index.
472        index: usize,
473        /// Current successor sequence length.
474        len: usize,
475    },
476
477    /// Failed on write successors
478    #[error("Failed on write successors")]
479    FailedToWriteSuccessors,
480
481    /// Failed on TryInto Entry
482    #[error("Failed on TryInto Entry")]
483    PeerRingInvalidEntry,
484
485    /// Unexpected PeerRingAction, {0:?}
486    #[error("Unexpected PeerRingAction, {0:?}")]
487    PeerRingUnexpectedAction(Box<crate::dht::PeerRingAction>),
488
489    /// PeerRing findsuccessor error, {0}
490    #[error("PeerRing findsuccessor error, {0}")]
491    PeerRingFindSuccessor(String),
492
493    /// PeerRing cannot find closest preceding node
494    #[error("PeerRing cannot find closest preceding node")]
495    PeerRingNotFindClosestNode,
496
497    /// PeerRing RWLock unlock failed
498    #[error("PeerRing RWLock unlock failed")]
499    PeerRingUnlockFailed,
500
501    /// Cannot seek did in swarm table, {0}
502    #[error("Cannot seek did in swarm table, {0}")]
503    SwarmMissDidInTable(crate::dht::Did),
504
505    /// Cannot gather local candidate, {0}
506    #[error("Cannot gather local candidate, {0}")]
507    FailedOnGatherLocalCandidate(String),
508
509    /// Node behaviour bad
510    #[error("Node behaviour bad")]
511    NodeBehaviourBad(crate::dht::Did),
512
513    /// Cannot get transport from did: {0}
514    #[error("Cannot get transport from did: {0}")]
515    SwarmMissTransport(crate::dht::Did),
516
517    /// Load message failed with message: {0}
518    #[error("Load message failed with message: {0}")]
519    SwarmLoadMessageRecvFailed(String),
520
521    /// Default transport is not connected
522    #[error("Default transport is not connected")]
523    SwarmDefaultTransportNotConnected,
524
525    /// call lock() failed
526    #[error("call lock() failed")]
527    SwarmPendingTransTryLockFailed,
528
529    /// transport not found
530    #[error("transport not found")]
531    SwarmPendingTransNotFound,
532
533    /// failed to close previous when registering, {0}
534    #[error("failed to close previous when registering, {0}")]
535    SwarmToClosePrevTransport(String),
536
537    /// call lock() failed
538    #[error("call lock() failed")]
539    SessionTryLockFailed,
540
541    /// Invalid peer type
542    #[error("Invalid peer type")]
543    InvalidPeerType,
544
545    #[cfg(not(all(feature = "wasm", target_family = "wasm")))]
546    /// RTC new peer connection failed
547    #[error("RTC new peer connection failed")]
548    RTCPeerConnectionCreateFailed(#[source] webrtc::Error),
549
550    /// RTC peer_connection not establish
551    #[error("RTC peer_connection not establish")]
552    RTCPeerConnectionNotEstablish,
553
554    #[cfg(not(all(feature = "wasm", target_family = "wasm")))]
555    /// RTC peer_connection fail to create offer
556    #[error("RTC peer_connection fail to create offer")]
557    RTCPeerConnectionCreateOfferFailed(#[source] webrtc::Error),
558
559    #[cfg(all(feature = "wasm", target_family = "wasm"))]
560    /// RTC peer_connection fail to create offer
561    #[error("RTC peer_connection fail to create offer")]
562    RTCPeerConnectionCreateOfferFailed(String),
563
564    #[cfg(not(all(feature = "wasm", target_family = "wasm")))]
565    /// RTC peer_connection fail to create answer
566    #[error("RTC peer_connection fail to create answer")]
567    RTCPeerConnectionCreateAnswerFailed(#[source] webrtc::Error),
568
569    #[cfg(all(feature = "wasm", target_family = "wasm"))]
570    /// RTC peer_connection fail to create answer
571    #[error("RTC peer_connection fail to create answer")]
572    RTCPeerConnectionCreateAnswerFailed(String),
573
574    /// DataChannel message size not match, {0} < {1}
575    #[error("DataChannel message size not match, {0} < {1}")]
576    RTCDataChannelMessageIncomplete(usize, usize),
577
578    #[cfg(not(all(feature = "wasm", target_family = "wasm")))]
579    /// DataChannel send text message failed
580    #[error("DataChannel send text message failed")]
581    RTCDataChannelSendTextFailed(#[source] webrtc::Error),
582
583    #[cfg(all(feature = "wasm", target_family = "wasm"))]
584    /// DataChannel send text message failed, {0}
585    #[error("DataChannel send text message failed, {0}")]
586    RTCDataChannelSendTextFailed(String),
587
588    /// DataChannel not ready
589    #[error("DataChannel not ready")]
590    RTCDataChannelNotReady,
591
592    /// DataChannel state not open
593    #[error("DataChannel state not open")]
594    RTCDataChannelStateNotOpen,
595
596    /// The observed WebRTC/data-channel product state cannot make progress.
597    #[error("Transport not ready: state {state:?}, data channel open: {data_channel_open}")]
598    TransportNotReady {
599        /// Observed WebRTC peer-connection state.
600        state: rings_transport::core::transport::WebrtcConnectionState,
601        /// Whether every transport data channel reported open.
602        data_channel_open: bool,
603    },
604
605    #[cfg(not(all(feature = "wasm", target_family = "wasm")))]
606    /// RTC peer_connection add ice candidate error
607    #[error("RTC peer_connection add ice candidate error")]
608    RTCPeerConnectionAddIceCandidateError(#[source] webrtc::Error),
609
610    #[cfg(all(feature = "wasm", target_family = "wasm"))]
611    /// RTC peer_connection add ice candidate error
612    #[error("RTC peer_connection add ice candidate error")]
613    RTCPeerConnectionAddIceCandidateError(String),
614
615    #[cfg(not(all(feature = "wasm", target_family = "wasm")))]
616    /// RTC peer_connection set local description failed
617    #[error("RTC peer_connection set local description failed")]
618    RTCPeerConnectionSetLocalDescFailed(#[source] webrtc::Error),
619
620    #[cfg(all(feature = "wasm", target_family = "wasm"))]
621    /// RTC peer_connection set local description failed
622    #[error("RTC peer_connection set local description failed")]
623    RTCPeerConnectionSetLocalDescFailed(String),
624
625    #[cfg(not(all(feature = "wasm", target_family = "wasm")))]
626    /// RTC peer_connection set remote description failed
627    #[error("RTC peer_connection set remote description failed")]
628    RTCPeerConnectionSetRemoteDescFailed(#[source] webrtc::Error),
629
630    #[cfg(all(feature = "wasm", target_family = "wasm"))]
631    /// RTC peer_connection set remote description failed
632    #[error("RTC peer_connection set remote description failed")]
633    RTCPeerConnectionSetRemoteDescFailed(String),
634
635    #[cfg(not(all(feature = "wasm", target_family = "wasm")))]
636    /// RTC peer_connection failed to close it
637    #[error("RTC peer_connection failed to close it")]
638    RTCPeerConnectionCloseFailed(#[source] webrtc::Error),
639
640    /// RTC unsupported sdp type
641    #[error("RTC unsupported sdp type")]
642    RTCSdpTypeNotMatch,
643
644    /// Connection not Found
645    #[error("Connection not Found")]
646    ConnectionNotFound,
647
648    /// Invalid Transport Id
649    #[error("Invalid Transport Id")]
650    InvalidTransportUuid,
651
652    /// Unexpected encrypted data
653    #[error("Unexpected encrypted data")]
654    UnexpectedEncryptedData,
655
656    /// Failed to decrypt data
657    #[error("Failed to decrypt data")]
658    DecryptionError,
659
660    /// Current node is not the next hop of message
661    #[error("Current node is not the next hop of message")]
662    InvalidNextHop,
663
664    /// Adjacent elements in path cannot be equal
665    #[error("Adjacent elements in path cannot be equal")]
666    InvalidRelayPath,
667
668    /// Suspected infinite looping in path
669    #[error("Suspected infinite looping in path")]
670    InfiniteRelayPath,
671
672    /// The destination of report message should always be the first element of path
673    #[error("The destination of report message should always be the first element of path")]
674    InvalidRelayDestination,
675
676    /// Cannot infer next hop
677    #[error("Cannot infer next hop")]
678    CannotInferNextHop,
679
680    /// Cannot get next hop when sending message
681    #[error("Cannot get next hop when sending message")]
682    NoNextHop,
683
684    /// To generate REPORT, you should provide SEND
685    #[error("To generate REPORT, you should provide SEND")]
686    ReportNeedSend,
687
688    /// Only SEND message can reset destination
689    #[error("Only SEND message can reset destination")]
690    ResetDestinationNeedSend,
691
692    #[cfg(all(feature = "wasm", target_family = "wasm"))]
693    /// IndexedDB error, {0}
694    #[error("IndexedDB error, {0}")]
695    IDBError(rexie::Error),
696
697    /// Invalid capacity value
698    #[error("Invalid capacity value")]
699    InvalidCapacity,
700
701    /// entry not found
702    #[error("entry not found")]
703    EntryNotFound,
704
705    /// IO error: {0}
706    #[error("IO error: {0}")]
707    IOError(std::io::Error),
708
709    /// Failed to get dht from a sync lock
710    #[error("Failed to get dht from a sync lock")]
711    DHTSyncLockError,
712
713    /// Failed to lock callback of swarm
714    #[error("Failed to lock callback of swarm")]
715    CallbackSyncLockError,
716
717    /// Failed to build swarm: {0}
718    #[error("Failed to build swarm: {0}")]
719    SwarmBuildFailed(String),
720
721    /// Message invalid: {0}
722    #[error("Message invalid: {0}")]
723    InvalidMessage(String),
724
725    /// Message encryption failed
726    #[error("Message encryption failed")]
727    MessageEncryptionFailed(String),
728
729    /// Message decryption failed
730    #[error("Message decryption failed")]
731    MessageDecryptionFailed(String),
732
733    /// Message has {0} bytes which is too large
734    #[error("Message has {0} bytes which is too large")]
735    MessageTooLarge(usize),
736
737    /// A serialized message size cannot be represented by the local platform.
738    #[error("Serialized message size exceeds the local platform limit")]
739    MessageSizeOverflow,
740
741    /// Peer's negotiated max_message_size {0} is too small to carry even one chunk
742    #[error("Peer's negotiated max_message_size {0} is too small to carry even one chunk")]
743    PeerMaxMessageSizeTooSmall(usize),
744
745    /// Timed out while waiting for the data-channel send queue to accept bytes
746    #[error(
747        "Timed out after {timeout_ms}ms waiting for data-channel send queue to accept {bytes} bytes for {peer} during {context}"
748    )]
749    DataChannelSendQueueTimeout {
750        /// Peer whose data-channel send queue did not accept the bytes.
751        peer: crate::dht::Did,
752        /// Timeout budget in milliseconds.
753        timeout_ms: u128,
754        /// Serialized bytes that were waiting to be accepted.
755        bytes: usize,
756        /// Send context used for diagnostics.
757        context: &'static str,
758    },
759    /// Timed out after the backend crossed its final cancellable send boundary.
760    #[error(
761        "Timed out after {timeout_ms}ms completing an irrevocable {bytes}-byte data-channel send to {peer} during {context}"
762    )]
763    DataChannelSendCompletionTimeout {
764        /// Peer whose irrevocable backend send did not complete.
765        peer: crate::dht::Did,
766        /// Completion timeout budget in milliseconds.
767        timeout_ms: u128,
768        /// Number of bytes owned by the backend send.
769        bytes: usize,
770        /// Scheduler phase that issued the send.
771        context: &'static str,
772    },
773
774    /// Timed out while waiting for accepted data-channel bytes to leave the local buffer.
775    #[error(
776        "Timed out after {timeout_ms}ms waiting for data-channel delivery to {peer} during {context}"
777    )]
778    DataChannelDeliveryTimeout {
779        /// Peer whose accepted bytes did not leave the local send buffer.
780        peer: crate::dht::Did,
781        /// Delivery timeout budget in milliseconds.
782        timeout_ms: u128,
783        /// Send context used for diagnostics.
784        context: &'static str,
785    },
786
787    /// A tracked transfer did not stop within its post-deadline cleanup grace.
788    #[error(
789        "Tracked payload cleanup for {peer} exceeded its {timeout_ms}ms grace after the send deadline"
790    )]
791    TrackedPayloadCleanupTimeout {
792        /// Peer whose exact connection generation was made send-terminal.
793        peer: crate::dht::Did,
794        /// Cleanup grace in milliseconds.
795        timeout_ms: u128,
796    },
797
798    #[cfg(all(feature = "wasm", target_family = "wasm"))]
799    /// Cannot get property {0} from JsValue
800    #[error("Cannot get property {0} from JsValue")]
801    FailedOnGetProperty(String),
802
803    #[cfg(all(feature = "wasm", target_family = "wasm"))]
804    /// Cannot set property {0} from JsValue
805    #[error("Cannot set property {0} from JsValue")]
806    FailedOnSetProperty(String),
807
808    #[cfg(all(feature = "wasm", target_family = "wasm"))]
809    /// Error on ser/der JsValue
810    #[error("Error on ser/der JsValue")]
811    SerdeWasmBindgenError(#[from] serde_wasm_bindgen::Error),
812
813    #[cfg(all(feature = "wasm", target_family = "wasm"))]
814    /// Error create RTC connection: {0}
815    #[error("Error create RTC connection: {0}")]
816    CreateConnectionError(String),
817
818    /// Session is expired
819    #[error("Session is expired")]
820    SessionExpired,
821
822    /// Transport error: {0}
823    #[error("Transport error: {0}")]
824    Transport(#[from] rings_transport::error::Error),
825
826    /// External Javascript error: {0}
827    #[error("External Javascript error: {0}")]
828    JsError(String),
829}