1#![allow(dead_code)]
8
9use std::io;
10use std::net;
11use std::net::SocketAddr;
12use std::num::ParseIntError;
13use std::string::FromUtf8Error;
14use std::time::SystemTimeError;
15use substring::Substring;
16use thiserror::Error;
17
18pub type Result<T> = std::result::Result<T, Error>;
20
21#[derive(Error, Debug, PartialEq)]
31#[non_exhaustive]
32pub enum Error {
33 #[error("buffer: full")]
35 ErrBufferFull,
36 #[error("buffer: closed")]
38 ErrBufferClosed,
39 #[error("buffer: short")]
41 ErrBufferShort,
42 #[error("packet too big")]
44 ErrPacketTooBig,
45 #[error("i/o timeout")]
47 ErrTimeout,
48 #[error("udp: listener closed")]
50 ErrClosedListener,
51 #[error("udp: listen queue exceeded")]
53 ErrListenQueueExceeded,
54 #[error("udp: listener accept ch closed")]
56 ErrClosedListenerAcceptCh,
57 #[error("obs cannot be nil")]
59 ErrObsCannotBeNil,
60 #[error("se of closed network connection")]
62 ErrUseClosedNetworkConn,
63 #[error("addr is not a net.UDPAddr")]
65 ErrAddrNotUdpAddr,
66 #[error("something went wrong with locAddr")]
68 ErrLocAddr,
69 #[error("already closed")]
71 ErrAlreadyClosed,
72 #[error("no remAddr defined")]
74 ErrNoRemAddr,
75 #[error("address already in use")]
77 ErrAddressAlreadyInUse,
78 #[error("no such UDPConn")]
80 ErrNoSuchUdpConn,
81 #[error("cannot remove unspecified IP by the specified IP")]
83 ErrCannotRemoveUnspecifiedIp,
84 #[error("no address assigned")]
86 ErrNoAddressAssigned,
87 #[error("1:1 NAT requires more than one mapping")]
89 ErrNatRequriesMapping,
90 #[error("length mismtach between mappedIPs and localIPs")]
92 ErrMismatchLengthIp,
93 #[error("non-udp translation is not supported yet")]
95 ErrNonUdpTranslationNotSupported,
96 #[error("no associated local address")]
98 ErrNoAssociatedLocalAddress,
99 #[error("no NAT binding found")]
101 ErrNoNatBindingFound,
102 #[error("has no permission")]
104 ErrHasNoPermission,
105 #[error("host name must not be empty")]
107 ErrHostnameEmpty,
108 #[error("failed to parse IP address")]
110 ErrFailedToParseIpaddr,
111 #[error("no interface is available")]
113 ErrNoInterface,
114 #[error("not found")]
116 ErrNotFound,
117 #[error("unexpected network")]
119 ErrUnexpectedNetwork,
120 #[error("can't assign requested address")]
122 ErrCantAssignRequestedAddr,
123 #[error("unknown network")]
125 ErrUnknownNetwork,
126 #[error("no router linked")]
128 ErrNoRouterLinked,
129 #[error("invalid port number")]
131 ErrInvalidPortNumber,
132 #[error("unexpected type-switch failure")]
134 ErrUnexpectedTypeSwitchFailure,
135 #[error("bind failed")]
137 ErrBindFailed,
138 #[error("end port is less than the start")]
140 ErrEndPortLessThanStart,
141 #[error("port space exhausted")]
143 ErrPortSpaceExhausted,
144 #[error("vnet is not enabled")]
146 ErrVnetDisabled,
147 #[error("invalid local IP in static_ips")]
149 ErrInvalidLocalIpInStaticIps,
150 #[error("mapped in static_ips is beyond subnet")]
152 ErrLocalIpBeyondStaticIpsSubset,
153 #[error("all static_ips must have associated local IPs")]
155 ErrLocalIpNoStaticsIpsAssociated,
156 #[error("router already started")]
158 ErrRouterAlreadyStarted,
159 #[error("router already stopped")]
161 ErrRouterAlreadyStopped,
162 #[error("static IP is beyond subnet")]
164 ErrStaticIpIsBeyondSubnet,
165 #[error("address space exhausted")]
167 ErrAddressSpaceExhausted,
168 #[error("no IP address is assigned for eth0")]
170 ErrNoIpaddrEth0,
171 #[error("Invalid mask")]
173 ErrInvalidMask,
174
175 #[error("tls handshake is in progress")]
178 HandshakeInProgress,
179 #[error("context is not supported for export_keying_material")]
181 ContextUnsupported,
182 #[error("export_keying_material can not be used with a reserved label")]
184 ReservedExportKeyingMaterial,
185 #[error("no cipher suite for export_keying_material")]
187 CipherSuiteUnset,
188 #[error("the exporter secret was erased: nothing more can be exported")]
191 ExporterSecretForgotten,
192 #[error("export_keying_material hash: {0}")]
194 Hash(String),
195 #[error("mutex poison: {0}")]
197 PoisonError(String),
198
199 #[error("Wrong marshal size")]
202 WrongMarshalSize,
203 #[error("Invalid total lost count")]
206 InvalidTotalLost,
207 #[error("Invalid header")]
209 InvalidHeader,
210 #[error("Empty compound packet")]
212 EmptyCompound,
213 #[error("First packet in compound must be SR or RR")]
216 BadFirstPacket,
217 #[error("Compound missing SourceDescription with CNAME")]
219 MissingCname,
220 #[error("Feedback packet seen before CNAME")]
222 PacketBeforeCname,
223 #[error("Too many reports")]
225 TooManyReports,
226 #[error("Too many chunks")]
228 TooManyChunks,
229 #[error("too many sources")]
231 TooManySources,
232 #[error("Packet too short to be read")]
234 PacketTooShort,
235 #[error("Buffer too short to be written")]
237 BufferTooShort,
238 #[error("Wrong packet type")]
240 WrongType,
241 #[error("SDES must be < 255 octets long")]
243 SdesTextTooLong,
244 #[error("SDES item missing type")]
246 SdesMissingType,
247 #[error("an RTCP CNAME must be 1 to 255 octets long")]
250 ErrRtcpCnameLength,
251 #[error("Reason must be < 255 octets long")]
253 ReasonTooLong,
254 #[error("Invalid packet version")]
256 BadVersion,
257 #[error("Invalid padding value")]
259 WrongPadding,
260 #[error("Wrong feedback message type")]
262 WrongFeedbackType,
263 #[error("Wrong payload type")]
265 WrongPayloadType,
266 #[error("Header length is too small")]
268 HeaderTooSmall,
269 #[error("Media SSRC must be 0")]
271 SsrcMustBeZero,
272 #[error("Missing REMB identifier")]
274 MissingRembIdentifier,
275 #[error("SSRC num and length do not match")]
277 SsrcNumAndLengthMismatch,
278 #[error("Invalid size or startIndex")]
280 InvalidSizeOrStartIndex,
281 #[error("Delta exceed limit")]
283 DeltaExceedLimit,
284 #[error("Packet status chunk must be 2 bytes")]
286 PacketStatusChunkLength,
287 #[error("Invalid bitrate")]
289 InvalidBitrate,
290 #[error("Wrong chunk type")]
292 WrongChunkType,
293 #[error("Struct contains unexpected member type")]
295 BadStructMemberType,
296 #[error("Cannot read into non-pointer")]
298 BadReadParameter,
299 #[error("Invalid block size")]
301 InvalidBlockSize,
302
303 #[error("RTP header size insufficient")]
306 ErrHeaderSizeInsufficient,
307 #[error("RTP header size insufficient for extension")]
309 ErrHeaderSizeInsufficientForExtension,
310 #[error("buffer too small")]
312 ErrBufferTooSmall,
313 #[error("extension not enabled")]
315 ErrHeaderExtensionsNotEnabled,
316 #[error("extension not found")]
318 ErrHeaderExtensionNotFound,
319
320 #[error("header extension id must be between 1 and 14 for RFC 5285 extensions")]
322 ErrRfc8285oneByteHeaderIdrange,
323 #[error("header extension payload must be 16bytes or less for RFC 5285 one byte extensions")]
325 ErrRfc8285oneByteHeaderSize,
326
327 #[error("header extension id must be between 1 and 255 for RFC 5285 extensions")]
329 ErrRfc8285twoByteHeaderIdrange,
330 #[error("header extension payload must be 255bytes or less for RFC 5285 two byte extensions")]
332 ErrRfc8285twoByteHeaderSize,
333
334 #[error("header extension id must be 0 for none RFC 5285 extensions")]
336 ErrRfc3550headerIdrange,
337
338 #[error("packet is not large enough")]
340 ErrShortPacket,
341 #[error("invalid nil packet")]
343 ErrNilPacket,
344 #[error("too many PDiff")]
346 ErrTooManyPDiff,
347 #[error("too many spatial layers")]
349 ErrTooManySpatialLayers,
350 #[error("NALU Type is unhandled")]
352 ErrUnhandledNaluType,
353
354 #[error("corrupted h265 packet")]
356 ErrH265CorruptedPacket,
357 #[error("invalid h265 packet type")]
359 ErrInvalidH265PacketType,
360
361 #[error("payload is too small for OBU extension header")]
363 ErrPayloadTooSmallForObuExtensionHeader,
364 #[error("payload is too small for OBU payload size")]
366 ErrPayloadTooSmallForObuPayloadSize,
367
368 #[error("extension_payload must be in 32-bit words")]
370 HeaderExtensionPayloadNot32BitWords,
371 #[error("too many CSRCs: {0} exceeds the 4-bit CC field maximum of 15")]
373 TooManyCSRCs(usize),
374 #[error(
376 "one-byte header extension payload length {0} is outside the RFC 8285 valid range of 1-16 bytes"
377 )]
378 OneByteHeaderExtensionPayloadOutOfRange(usize),
379 #[error(
381 "two-byte header extension payload length {0} exceeds the RFC 8285 maximum of 255 bytes"
382 )]
383 TwoByteHeaderExtensionPayloadTooLarge(usize),
384 #[error("total extension payload length {0} exceeds u16::MAX (65535 bytes)")]
386 ExtensionPayloadTotalOverflow(usize),
387 #[error("NALU length {0} exceeds u16::MAX (65535 bytes)")]
389 NaluTooLarge(usize),
390 #[error("audio level overflow")]
392 AudioLevelOverflow,
393 #[error("playout delay overflow")]
395 PlayoutDelayOverflow,
396 #[error("payload is not large enough")]
398 PayloadIsNotLargeEnough,
399 #[error("STAP-A declared size({0}) is larger than buffer({1})")]
401 StapASizeLargerThanBuffer(usize, usize),
402 #[error("nalu type {0} is currently not handled")]
404 NaluTypeIsNotHandled(u8),
405
406 #[error("duplicated packet")]
409 ErrDuplicated,
410 #[error("SRTP master key is not long enough")]
412 ErrShortSrtpMasterKey,
413 #[error("SRTP master salt is not long enough")]
415 ErrShortSrtpMasterSalt,
416 #[error("no such SRTP Profile")]
418 ErrNoSuchSrtpProfile,
419 #[error("indexOverKdr > 0 is not supported yet")]
421 ErrNonZeroKdrNotSupported,
422 #[error("exporter called with wrong label")]
424 ErrExporterWrongLabel,
425 #[error("no config provided")]
427 ErrNoConfig,
428 #[error("no conn provided")]
430 ErrNoConn,
431 #[error("failed to verify auth tag")]
433 ErrFailedToVerifyAuthTag,
434 #[error("packet is too short to be RTP packet")]
436 ErrTooShortRtp,
437 #[error("packet is too short to be RTCP packet")]
439 ErrTooShortRtcp,
440 #[error("payload differs")]
442 ErrPayloadDiffers,
443 #[error("started channel used incorrectly, should only be closed")]
445 ErrStartedChannelUsedIncorrectly,
446 #[error("stream has not been inited, unable to close")]
448 ErrStreamNotInited,
449 #[error("stream is already closed")]
451 ErrStreamAlreadyClosed,
452 #[error("stream is already inited")]
454 ErrStreamAlreadyInited,
455 #[error("failed to cast child")]
457 ErrFailedTypeAssertion,
458 #[error("exceeded the maximum number of packets")]
460 ErrExceededMaxPackets,
461
462 #[error("index_over_kdr > 0 is not supported yet")]
464 UnsupportedIndexOverKdr,
465 #[error("invalid master key length for aes_256_cm")]
467 InvalidMasterKeyLength,
468 #[error("invalid master salt length for aes_256_cm")]
470 InvalidMasterSaltLength,
471 #[error("out_len > 32 is not supported for aes_256_cm")]
473 UnsupportedOutLength,
474 #[error("SRTP Master Key must be len {0}, got {1}")]
476 SrtpMasterKeyLength(usize, usize),
477 #[error("SRTP Salt must be len {0}, got {1}")]
479 SrtpSaltLength(usize, usize),
480 #[error("SyntaxError: {0}")]
482 ExtMapParse(String),
483 #[error("ssrc {0} not exist in srtp_ssrc_state")]
485 SsrcMissingFromSrtp(u32),
486 #[error("srtp ssrc={0} index={1}: duplicated")]
488 SrtpSsrcDuplicated(u32, u16),
489 #[error("srtp ssrc={0} seq={1}: packet index already used for encryption")]
491 SrtpIndexReused(u32, u16),
492 #[error("srtp ssrc={0}: refused, the context already tracks {1} SSRCs")]
494 SrtpTooManySsrcs(u32, usize),
495 #[error("srtcp ssrc={0} index={1}: duplicated")]
497 SrtcpSsrcDuplicated(u32, usize),
498 #[error("ssrc {0} not exist in srtcp_ssrc_state")]
500 SsrcMissingFromSrtcp(u32),
501 #[error("Stream with ssrc {0} exists")]
503 StreamWithSsrcExists(u32),
504 #[error("Session RTP/RTCP type must be same as input buffer")]
506 SessionRtpRtcpTypeMismatch,
507 #[error("Session EOF")]
509 SessionEof,
510 #[error("too short SRTP packet: only {0} bytes, expected > {1} bytes")]
512 SrtpTooSmall(usize, usize),
513 #[error("too short SRTCP packet: only {0} bytes, expected > {1} bytes")]
515 SrtcpTooSmall(usize, usize),
516 #[error("failed to verify rtp auth tag")]
518 RtpFailedToVerifyAuthTag,
519 #[error("too short auth tag: only {0} bytes, expected > {1} bytes")]
521 RtcpInvalidLengthAuthTag(usize, usize),
522 #[error("failed to verify rtcp auth tag")]
524 RtcpFailedToVerifyAuthTag,
525 #[error("SessionSRTP has been closed")]
527 SessionSrtpAlreadyClosed,
528 #[error("this stream is not a RTPStream")]
530 InvalidRtpStream,
531 #[error("this stream is not a RTCPStream")]
533 InvalidRtcpStream,
534
535 #[error("attribute not found")]
538 ErrAttributeNotFound,
539 #[error("transaction is stopped")]
541 ErrTransactionStopped,
542 #[error("transaction not exists")]
544 ErrTransactionNotExists,
545 #[error("transaction exists with same id")]
547 ErrTransactionExists,
548 #[error("agent is closed")]
550 ErrAgentClosed,
551 #[error("transaction is timed out")]
553 ErrTransactionTimeOut,
554 #[error("no default reason for ErrorCode")]
556 ErrNoDefaultReason,
557 #[error("unexpected EOF")]
559 ErrUnexpectedEof,
560 #[error("attribute size is invalid")]
562 ErrAttributeSizeInvalid,
563 #[error("attribute size overflow")]
565 ErrAttributeSizeOverflow,
566 #[error("attempt to decode to nil message")]
568 ErrDecodeToNil,
569 #[error("unexpected EOF: not enough bytes to read header")]
571 ErrUnexpectedHeaderEof,
572 #[error("integrity check failed")]
574 ErrIntegrityMismatch,
575 #[error("fingerprint check failed")]
577 ErrFingerprintMismatch,
578 #[error("FINGERPRINT before MESSAGE-INTEGRITY attribute")]
580 ErrFingerprintBeforeIntegrity,
581 #[error("bad UNKNOWN-ATTRIBUTES size")]
583 ErrBadUnknownAttrsSize,
584 #[error("invalid length of IP value")]
586 ErrBadIpLength,
587 #[error("no connection provided")]
589 ErrNoConnection,
590 #[error("client is closed")]
592 ErrClientClosed,
593 #[error("no agent is set")]
595 ErrNoAgent,
596 #[error("collector is closed")]
598 ErrCollectorClosed,
599 #[error("unsupported network")]
601 ErrUnsupportedNetwork,
602 #[error("invalid url")]
604 ErrInvalidUrl,
605 #[error("unknown scheme type")]
607 ErrSchemeType,
608 #[error("invalid hostname")]
610 ErrHost,
611
612 #[error("turn: RelayAddress must be valid IP to use RelayAddressGeneratorStatic")]
615 ErrRelayAddressInvalid,
616 #[error("turn: PacketConnConfigs and ConnConfigs are empty, unable to proceed")]
618 ErrNoAvailableConns,
619 #[error("turn: PacketConnConfig must have a non-nil Conn")]
621 ErrConnUnset,
622 #[error("turn: ListenerConfig must have a non-nil Listener")]
624 ErrListenerUnset,
625 #[error("turn: RelayAddressGenerator has invalid ListeningAddress")]
627 ErrListeningAddressInvalid,
628 #[error("turn: RelayAddressGenerator in RelayConfig is unset")]
630 ErrRelayAddressGeneratorUnset,
631 #[error("turn: max retries exceeded")]
633 ErrMaxRetriesExceeded,
634 #[error("turn: MaxPort must be not 0")]
636 ErrMaxPortNotZero,
637 #[error("turn: MaxPort must be not 0")]
639 ErrMinPortNotZero,
640 #[error("turn: MaxPort less than MinPort")]
642 ErrMaxPortLessThanMinPort,
643 #[error("turn: relay_conn cannot not be nil")]
645 ErrNilConn,
646 #[error("turn: TODO")]
648 ErrTodo,
649 #[error("turn: already listening")]
651 ErrAlreadyListening,
652 #[error("turn: Server failed to close")]
654 ErrFailedToClose,
655 #[error("turn: failed to retransmit transaction")]
657 ErrFailedToRetransmitTransaction,
658 #[error("all retransmissions failed")]
660 ErrAllRetransmissionsFailed,
661 #[error("no binding found for channel")]
663 ErrChannelBindNotFound,
664 #[error("STUN server address is not set for the client")]
666 ErrStunserverAddressNotSet,
667 #[error("only one Allocate() caller is allowed")]
669 ErrOneAllocateOnly,
670 #[error("already allocated")]
672 ErrAlreadyAllocated,
673 #[error("non-STUN message from STUN server")]
675 ErrNonStunmessage,
676 #[error("failed to decode STUN message")]
678 ErrFailedToDecodeStun,
679 #[error("unexpected STUN request message")]
681 ErrUnexpectedStunrequestMessage,
682 #[error("channel number not in [0x4000, 0x7FFF]")]
684 ErrInvalidChannelNumber,
685 #[error("channelData length != len(Data)")]
687 ErrBadChannelDataLength,
688 #[error("invalid value for requested family attribute")]
690 ErrInvalidRequestedFamilyValue,
691 #[error("fake error")]
693 ErrFakeErr,
694 #[error("use of closed network connection")]
696 ErrClosed,
697 #[error("addr is not a net.UDPAddr")]
699 ErrUdpaddrCast,
700 #[error("try-lock is already locked")]
702 ErrDoubleLock,
703 #[error("transaction closed")]
705 ErrTransactionClosed,
706 #[error("wait_for_result called on non-result transaction")]
708 ErrWaitForResultOnNonResultTransaction,
709 #[error("failed to build refresh request")]
711 ErrFailedToBuildRefreshRequest,
712 #[error("failed to refresh allocation")]
714 ErrFailedToRefreshAllocation,
715 #[error("failed to get lifetime from refresh response")]
717 ErrFailedToGetLifetime,
718 #[error("too short buffer")]
720 ErrShortBuffer,
721 #[error("unexpected response type")]
723 ErrUnexpectedResponse,
724 #[error("AllocatePacketConn must be set")]
726 ErrAllocatePacketConnMustBeSet,
727 #[error("AllocateConn must be set")]
729 ErrAllocateConnMustBeSet,
730 #[error("LeveledLogger must be set")]
732 ErrLeveledLoggerMustBeSet,
733 #[error("you cannot use the same channel number with different peer")]
735 ErrSameChannelDifferentPeer,
736 #[error("allocations must not be created with nil FivTuple")]
738 ErrNilFiveTuple,
739 #[error("allocations must not be created with nil FiveTuple.src_addr")]
741 ErrNilFiveTupleSrcAddr,
742 #[error("allocations must not be created with nil FiveTuple.dst_addr")]
744 ErrNilFiveTupleDstAddr,
745 #[error("allocations must not be created with nil turnSocket")]
747 ErrNilTurnSocket,
748 #[error("allocations must not be created with a lifetime of 0")]
750 ErrLifetimeZero,
751 #[error("allocation attempt created with duplicate FiveTuple")]
753 ErrDupeFiveTuple,
754 #[error("failed to cast net.Addr to *net.UDPAddr")]
756 ErrFailedToCastUdpaddr,
757 #[error("failed to generate nonce")]
759 ErrFailedToGenerateNonce,
760 #[error("failed to send error message")]
762 ErrFailedToSendError,
763 #[error("duplicated Nonce generated, discarding request")]
765 ErrDuplicatedNonce,
766 #[error("no such user exists")]
768 ErrNoSuchUser,
769 #[error("unexpected class")]
771 ErrUnexpectedClass,
772 #[error("unexpected method")]
774 ErrUnexpectedMethod,
775 #[error("failed to handle")]
777 ErrFailedToHandle,
778 #[error("unhandled STUN packet")]
780 ErrUnhandledStunpacket,
781 #[error("unable to handle ChannelData")]
783 ErrUnableToHandleChannelData,
784 #[error("failed to create stun message from packet")]
786 ErrFailedToCreateStunpacket,
787 #[error("failed to create channel data from packet")]
789 ErrFailedToCreateChannelData,
790 #[error("relay already allocated for 5-TUPLE")]
792 ErrRelayAlreadyAllocatedForFiveTuple,
793 #[error("RequestedTransport must be UDP")]
795 ErrRequestedTransportMustBeUdp,
796 #[error("no support for DONT-FRAGMENT")]
798 ErrNoDontFragmentSupport,
799 #[error("Request must not contain RESERVATION-TOKEN and EVEN-PORT")]
801 ErrRequestWithReservationTokenAndEvenPort,
802 #[error("no allocation found")]
804 ErrNoAllocationFound,
805 #[error("unable to handle send-indication, no permission added")]
807 ErrNoPermission,
808 #[error("packet write smaller than packet")]
810 ErrShortWrite,
811 #[error("no such channel bind")]
813 ErrNoSuchChannelBind,
814 #[error("failed writing to socket")]
816 ErrFailedWriteSocket,
817
818 #[error("Unknown type")]
821 ErrUnknownType,
822
823 #[error("queries not supported in stun address")]
825 ErrStunQuery,
826
827 #[error("invalid query")]
829 ErrInvalidQuery,
830
831 #[error("url parse: invalid port number")]
833 ErrPort,
834
835 #[error("local username fragment is less than 24 bits long")]
838 ErrLocalUfragInsufficientBits,
839
840 #[error("local password is less than 128 bits long")]
843 ErrLocalPwdInsufficientBits,
844
845 #[error("local username fragment is longer than 32 characters or not made of ice-chars")]
848 ErrLocalUfragInvalid,
849
850 #[error("local password is longer than 256 characters or not made of ice-chars")]
853 ErrLocalPwdInvalid,
854
855 #[error("a local srflx, prflx or relay candidate has no related address")]
858 ErrLocalCandidateWithoutRelatedAddress,
859
860 #[error("invalid transport protocol type")]
862 ErrProtoType,
863
864 #[error("no candidate pairs available")]
866 ErrNoCandidatePairs,
867
868 #[error("connecting canceled by caller")]
870 ErrCanceledByCaller,
871
872 #[error("attempted to start agent twice")]
874 ErrMultipleStart,
875
876 #[error("remote ufrag is empty")]
878 ErrRemoteUfragEmpty,
879
880 #[error("remote pwd is empty")]
882 ErrRemotePwdEmpty,
883
884 #[error("no on_candidate provided")]
886 ErrNoOnCandidateHandler,
887
888 #[error("attempting to gather candidates during gathering state")]
890 ErrMultipleGatherAttempted,
891
892 #[error("username is empty")]
894 ErrUsernameEmpty,
895
896 #[error("password is empty")]
898 ErrPasswordEmpty,
899
900 #[error("failed to parse address")]
902 ErrAddressParseFailed,
903
904 #[error("lite agents must only use host candidates")]
906 ErrLiteUsingNonHostCandidates,
907
908 #[error("lite support only")]
910 ErrLiteSupportOnly,
911
912 #[error("agent does not need URL with selected candidate types")]
914 ErrUselessUrlsProvided,
915
916 #[error("unsupported 1:1 NAT IP candidate type")]
918 ErrUnsupportedNat1to1IpCandidateType,
919
920 #[error("invalid 1:1 NAT IP mapping")]
922 ErrInvalidNat1to1IpMapping,
923
924 #[error("external mapped IP not found")]
926 ErrExternalMappedIpNotFound,
927
928 #[error("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate")]
931 ErrMulticastDnsWithNat1to1IpMapping,
932
933 #[error("1:1 NAT IP mapping for host candidate ineffective")]
936 ErrIneffectiveNat1to1IpMappingHost,
937
938 #[error("1:1 NAT IP mapping for srflx candidate ineffective")]
941 ErrIneffectiveNat1to1IpMappingSrflx,
942
943 #[error("invalid mDNS HostName, must end with .local and can only contain a single '.'")]
945 ErrInvalidMulticastDnshostName,
946
947 #[error("mdns is not supported")]
949 ErrMulticastDnsNotSupported,
950
951 #[error("ICE Agent can not be restarted when gathering")]
953 ErrRestartWhenGathering,
954
955 #[error("run was canceled by done")]
957 ErrRunCanceled,
958
959 #[error("TCPMux is not initialized")]
961 ErrTcpMuxNotInitialized,
962
963 #[error("conn with same remote addr already exists")]
965 ErrTcpRemoteAddrAlreadyExists,
966
967 #[error("failed to send packet")]
969 ErrSendPacket,
970 #[error("attribute not long enough to be ICE candidate")]
972 ErrAttributeTooShortIceCandidate,
973 #[error("could not parse component")]
975 ErrParseComponent,
976 #[error("could not parse priority")]
978 ErrParsePriority,
979 #[error("could not parse port")]
981 ErrParsePort,
982 #[error("could not parse related addresses")]
984 ErrParseRelatedAddr,
985 #[error("could not parse type")]
987 ErrParseType,
988 #[error("unknown candidate type")]
990 ErrUnknownCandidateType,
991 #[error("failed to get XOR-MAPPED-ADDRESS response")]
993 ErrGetXorMappedAddrResponse,
994 #[error("connection with same remote address already exists")]
996 ErrConnectionAddrAlreadyExist,
997 #[error("error reading streaming packet")]
999 ErrReadingStreamingPacket,
1000 #[error("error writing to")]
1002 ErrWriting,
1003 #[error("error closing connection")]
1005 ErrClosingConnection,
1006 #[error("unable to determine networkType")]
1008 ErrDetermineNetworkType,
1009 #[error("missing protocol scheme")]
1011 ErrMissingProtocolScheme,
1012 #[error("too many colons in address")]
1014 ErrTooManyColonsAddr,
1015 #[error("unexpected error trying to read")]
1017 ErrRead,
1018 #[error("unknown role")]
1020 ErrUnknownRole,
1021 #[error("username mismatch")]
1023 ErrMismatchUsername,
1024 #[error("the ICE conn can't write STUN messages")]
1026 ErrIceWriteStunMessage,
1027 #[error("url parse: relative URL without a base")]
1029 ErrUrlParse,
1030 #[error("Candidate IP could not be found")]
1032 ErrCandidateIpNotFound,
1033
1034 #[error("conn is closed")]
1037 ErrConnClosed,
1038 #[error("read/write timeout")]
1040 ErrDeadlineExceeded,
1041 #[error("context is not supported for export_keying_material")]
1043 ErrContextUnsupported,
1044 #[error("packet is too short")]
1046 ErrDtlspacketInvalidLength,
1047 #[error("handshake is in progress")]
1049 ErrHandshakeInProgress,
1050 #[error("invalid content type")]
1052 ErrInvalidContentType,
1053 #[error("invalid mac")]
1055 ErrInvalidMac,
1056 #[error("packet length and declared length do not match")]
1058 ErrInvalidPacketLength,
1059 #[error("export_keying_material can not be used with a reserved label")]
1061 ErrReservedExportKeyingMaterial,
1062 #[error("client sent certificate verify but we have no certificate to verify")]
1064 ErrCertificateVerifyNoCertificate,
1065 #[error("handshake message out of order")]
1068 ErrHandshakeMessageOutOfOrder,
1069 #[error("client+server do not support any shared cipher suites")]
1071 ErrCipherSuiteNoIntersection,
1072 #[error("server hello can not be created without a cipher suite")]
1074 ErrCipherSuiteUnset,
1075 #[error("client sent certificate but did not verify it")]
1077 ErrClientCertificateNotVerified,
1078 #[error("server required client verification, but got none")]
1080 ErrClientCertificateRequired,
1081 #[error("server responded with SRTP Profile we do not support")]
1083 ErrClientNoMatchingSrtpProfile,
1084 #[error("client required Extended Master Secret extension, but server does not support it")]
1086 ErrClientRequiredButNoServerEms,
1087 #[error("server hello can not be created without a compression method")]
1089 ErrCompressionMethodUnset,
1090 #[error("client+server cookie does not match")]
1092 ErrCookieMismatch,
1093 #[error("cookie must not be longer then 255 bytes")]
1095 ErrCookieTooLong,
1096 #[error("PSK Identity Hint provided but PSK is nil")]
1098 ErrIdentityNoPsk,
1099 #[error("no certificate provided")]
1101 ErrInvalidCertificate,
1102 #[error("cipher spec invalid")]
1104 ErrInvalidCipherSpec,
1105 #[error("invalid or unknown cipher suite")]
1107 ErrInvalidCipherSuite,
1108 #[error("unable to determine if ClientKeyExchange is a public key or PSK Identity")]
1110 ErrInvalidClientKeyExchange,
1111 #[error("invalid or unknown compression method")]
1113 ErrInvalidCompressionMethod,
1114 #[error("ECDSA signature contained zero or negative values")]
1116 ErrInvalidEcdsasignature,
1117 #[error("invalid or unknown elliptic curve type")]
1119 ErrInvalidEllipticCurveType,
1120 #[error("invalid extension type")]
1122 ErrInvalidExtensionType,
1123 #[error("invalid hash algorithm")]
1125 ErrInvalidHashAlgorithm,
1126 #[error("invalid named curve")]
1128 ErrInvalidNamedCurve,
1129 #[error("invalid private key type")]
1131 ErrInvalidPrivateKey,
1132 #[error("named curve and private key type does not match")]
1134 ErrNamedCurveAndPrivateKeyMismatch,
1135 #[error("invalid server name format")]
1137 ErrInvalidSniFormat,
1138 #[error("invalid signature algorithm")]
1140 ErrInvalidSignatureAlgorithm,
1141 #[error("expected and actual key signature do not match")]
1143 ErrKeySignatureMismatch,
1144 #[error("Conn can not be created with a nil nextConn")]
1146 ErrNilNextConn,
1147 #[error("connection can not be created, no CipherSuites satisfy this Config")]
1149 ErrNoAvailableCipherSuites,
1150 #[error("connection can not be created, no SignatureScheme satisfy this Config")]
1152 ErrNoAvailableSignatureSchemes,
1153 #[error("no certificates configured")]
1155 ErrNoCertificates,
1156 #[error("no config provided")]
1158 ErrNoConfigProvided,
1159 #[error("client requested zero or more elliptic curves that are not supported by the server")]
1161 ErrNoSupportedEllipticCurves,
1162 #[error("unsupported protocol version")]
1164 ErrUnsupportedProtocolVersion,
1165 #[error("Certificate and PSK provided")]
1167 ErrPskAndCertificate,
1168 #[error("PSK and PSK Identity Hint must both be set for client")]
1170 ErrPskAndIdentityMustBeSetForClient,
1171 #[error("SRTP support was requested but server did not respond with use_srtp extension")]
1173 ErrRequestedButNoSrtpExtension,
1174 #[error("Certificate is mandatory for server")]
1176 ErrServerMustHaveCertificate,
1177 #[error("client requested SRTP but we have no matching profiles")]
1179 ErrServerNoMatchingSrtpProfile,
1180 #[error(
1182 "server requires the Extended Master Secret extension, but the client does not support it"
1183 )]
1184 ErrServerRequiredButNoClientEms,
1185 #[error("expected and actual verify data does not match")]
1187 ErrVerifyDataMismatch,
1188 #[error("handshake message unset, unable to marshal")]
1190 ErrHandshakeMessageUnset,
1191 #[error("invalid flight number")]
1193 ErrInvalidFlight,
1194 #[error("unable to generate key signature, unimplemented")]
1196 ErrKeySignatureGenerateUnimplemented,
1197 #[error("unable to verify key signature, unimplemented")]
1199 ErrKeySignatureVerifyUnimplemented,
1200 #[error("data length and declared length do not match")]
1202 ErrLengthMismatch,
1203 #[error("buffer not long enough to contain nonce")]
1205 ErrNotEnoughRoomForNonce,
1206 #[error("feature has not been implemented yet")]
1208 ErrNotImplemented,
1209 #[error("sequence number overflow")]
1211 ErrSequenceNumberOverflow,
1212 #[error("unable to marshal fragmented handshakes")]
1214 ErrUnableToMarshalFragmented,
1215 #[error("invalid state machine transition")]
1217 ErrInvalidFsmTransition,
1218 #[error("ApplicationData with epoch of 0")]
1220 ErrApplicationDataEpochZero,
1221 #[error("unhandled contentType")]
1223 ErrUnhandledContextType,
1224 #[error("context canceled")]
1226 ErrContextCanceled,
1227 #[error("empty fragment")]
1229 ErrEmptyFragment,
1230 #[error("Alert is Fatal or Close Notify")]
1232 ErrAlertFatalOrClose,
1233 #[error("renegotiation_info is not empty in an initial handshake")]
1235 ErrRenegotiationInfoNotEmpty,
1236 #[error("server sent an extension the client did not offer")]
1238 ErrUnsolicitedExtension,
1239 #[error("server selected a compression method the client did not offer")]
1241 ErrCompressionMethodNotOffered,
1242 #[error("client did not offer the null compression method")]
1244 ErrNoNullCompressionMethod,
1245 #[error("server's use_srtp extension is not a valid answer to the client's")]
1248 ErrInvalidUseSrtpAnswer,
1249 #[error("no keying material is exported without the extended master secret")]
1251 ErrExportWithoutExtendedMasterSecret,
1252 #[error("handshake did not complete in time")]
1254 ErrHandshakeTimeout,
1255 #[error("record payload exceeds 2^14 bytes")]
1257 ErrRecordOverflow,
1258 #[error("hello carries an extension type twice")]
1260 ErrDuplicateExtension,
1261 #[error(
1263 "Fragment buffer overflow. New size {new_size} is greater than specified max {max_size}"
1264 )]
1265 ErrFragmentBufferOverflow {
1266 new_size: usize,
1268 max_size: usize,
1270 },
1271 #[error("Client transport is not set yet")]
1273 ErrClientTransportNotSet,
1274
1275 #[error("endpoint stopping")]
1279 EndpointStopping,
1280 #[error("too many connections")]
1284 TooManyConnections,
1285 #[error("invalid DNS name: {0}")]
1287 InvalidDnsName(String),
1288 #[error("invalid remote address: {0}")]
1292 InvalidRemoteAddress(SocketAddr),
1293 #[error("no client config")]
1295 NoClientConfig,
1296 #[error("no server config")]
1298 NoServerConfig,
1299
1300 #[error("raw is too small for a SCTP chunk")]
1303 ErrChunkHeaderTooSmall,
1304 #[error("not enough data left in SCTP packet to satisfy requested length")]
1306 ErrChunkHeaderNotEnoughSpace,
1307 #[error("chunk PADDING is non-zero at offset")]
1309 ErrChunkHeaderPaddingNonZero,
1310 #[error("chunk has invalid length")]
1312 ErrChunkHeaderInvalidLength,
1313
1314 #[error("ChunkType is not of type ABORT")]
1316 ErrChunkTypeNotAbort,
1317 #[error("failed build Abort Chunk")]
1319 ErrBuildAbortChunkFailed,
1320 #[error("ChunkType is not of type COOKIEACK")]
1322 ErrChunkTypeNotCookieAck,
1323 #[error("ChunkType is not of type COOKIEECHO")]
1325 ErrChunkTypeNotCookieEcho,
1326 #[error("ChunkType is not of type ctError")]
1328 ErrChunkTypeNotCt,
1329 #[error("failed build Error Chunk")]
1331 ErrBuildErrorChunkFailed,
1332 #[error("failed to marshal stream")]
1334 ErrMarshalStreamFailed,
1335 #[error("chunk too short")]
1337 ErrChunkTooShort,
1338 #[error("ChunkType is not of type ForwardTsn")]
1340 ErrChunkTypeNotForwardTsn,
1341 #[error("ChunkType is not of type HEARTBEAT")]
1343 ErrChunkTypeNotHeartbeat,
1344 #[error("ChunkType is not of type HEARTBEATACK")]
1346 ErrChunkTypeNotHeartbeatAck,
1347 #[error("heartbeat is not long enough to contain Heartbeat Info")]
1349 ErrHeartbeatNotLongEnoughInfo,
1350 #[error("failed to parse param type")]
1352 ErrParseParamTypeFailed,
1353 #[error("heartbeat should only have HEARTBEAT param")]
1355 ErrHeartbeatParam,
1356 #[error("failed unmarshalling param in Heartbeat Chunk")]
1358 ErrHeartbeatChunkUnmarshal,
1359 #[error("unimplemented")]
1361 ErrUnimplemented,
1362 #[error("heartbeat Ack must have one param")]
1364 ErrHeartbeatAckParams,
1365 #[error("heartbeat Ack must have one param, and it should be a HeartbeatInfo")]
1367 ErrHeartbeatAckNotHeartbeatInfo,
1368 #[error("unable to marshal parameter for Heartbeat Ack")]
1370 ErrHeartbeatAckMarshalParam,
1371
1372 #[error("raw is too small for error cause")]
1374 ErrErrorCauseTooSmall,
1375
1376 #[error("unhandled ParamType: {typ}")]
1378 ErrParamTypeUnhandled {
1379 typ: u16,
1381 },
1382
1383 #[error("unexpected ParamType")]
1385 ErrParamTypeUnexpected,
1386
1387 #[error("param header too short")]
1389 ErrParamHeaderTooShort,
1390 #[error("param self reported length is shorter than header length")]
1392 ErrParamHeaderSelfReportedLengthShorter,
1393 #[error("param self reported length is longer than header length")]
1395 ErrParamHeaderSelfReportedLengthLonger,
1396 #[error("failed to parse param type")]
1398 ErrParamHeaderParseFailed,
1399
1400 #[error("packet to short")]
1402 ErrParamPacketTooShort,
1403 #[error("outgoing SSN reset request parameter too short")]
1405 ErrSsnResetRequestParamTooShort,
1406 #[error("failed unmarshalling SSN reset request parameter in RE-CONFIG chunk")]
1408 ErrUnmarshalSsnResetRequestParam,
1409 #[error("reconfig response parameter too short")]
1411 ErrReconfigRespParamTooShort,
1412 #[error("failed unmarshalling re-configuration response parameter in RE-CONFIG chunk")]
1414 ErrUnmarshalReconfigRespParam,
1415 #[error("invalid algorithm type")]
1417 ErrInvalidAlgorithmType,
1418
1419 #[error("failed to parse param type")]
1421 ErrInitChunkParseParamTypeFailed,
1422 #[error("failed unmarshalling param in Init Chunk")]
1424 ErrInitChunkUnmarshalParam,
1425 #[error("unable to marshal parameter for INIT/INITACK")]
1427 ErrInitAckMarshalParam,
1428
1429 #[error("ChunkType is not of type INIT")]
1431 ErrChunkTypeNotTypeInit,
1432 #[error("chunk Value isn't long enough for mandatory parameters exp")]
1434 ErrChunkValueNotLongEnough,
1435 #[error("ChunkType of type INIT flags must be all 0")]
1437 ErrChunkTypeInitFlagZero,
1438 #[error("failed to unmarshal INIT body")]
1440 ErrChunkTypeInitUnmarshalFailed,
1441 #[error("failed marshaling INIT common data")]
1443 ErrChunkTypeInitMarshalFailed,
1444 #[error("ChunkType of type INIT ACK InitiateTag must not be 0")]
1446 ErrChunkTypeInitInitiateTagZero,
1447 #[error("INIT ACK inbound stream request must be > 0")]
1449 ErrInitInboundStreamRequestZero,
1450 #[error("INIT ACK outbound stream request must be > 0")]
1452 ErrInitOutboundStreamRequestZero,
1453 #[error("INIT ACK Advertised Receiver Window Credit (a_rwnd) must be >= 1500")]
1455 ErrInitAdvertisedReceiver1500,
1456
1457 #[error("packet is smaller than the header size")]
1459 ErrChunkPayloadSmall,
1460 #[error("ChunkType is not of type PayloadData")]
1462 ErrChunkTypeNotPayloadData,
1463 #[error("failed unmarshalling payload data chunk")]
1465 ErrChunkUnmarshalPayloadData,
1466 #[error("ChunkType is not of type Reconfig")]
1468 ErrChunkTypeNotReconfig,
1469 #[error("ChunkReconfig has invalid ParamA")]
1471 ErrChunkReconfigInvalidParamA,
1472
1473 #[error("failed to parse param type")]
1475 ErrChunkParseParamTypeFailed,
1476 #[error("unable to marshal parameter A for reconfig")]
1478 ErrChunkMarshalParamAReconfigFailed,
1479 #[error("unable to marshal parameter B for reconfig")]
1481 ErrChunkMarshalParamBReconfigFailed,
1482
1483 #[error("ChunkType is not of type SACK")]
1485 ErrChunkTypeNotSack,
1486 #[error("SACK Chunk size is not large enough to contain header")]
1488 ErrSackSizeNotLargeEnoughInfo,
1489 #[error("failed unmarshalling SACK chunk")]
1491 ErrChunkUnmarshalSack,
1492
1493 #[error("invalid chunk size")]
1495 ErrInvalidChunkSize,
1496 #[error("ChunkType is not of type SHUTDOWN")]
1498 ErrChunkTypeNotShutdown,
1499 #[error("failed unmarshalling shutdown chunk")]
1501 ErrChunkUnmarshalShutdown,
1502
1503 #[error("ChunkType is not of type SHUTDOWN-ACK")]
1505 ErrChunkTypeNotShutdownAck,
1506 #[error("ChunkType is not of type SHUTDOWN-COMPLETE")]
1508 ErrChunkTypeNotShutdownComplete,
1509
1510 #[error("raw is smaller than the minimum length for a SCTP packet")]
1512 ErrPacketRawTooSmall,
1513 #[error("unable to parse SCTP chunk, not enough data for complete header")]
1515 ErrParseSctpChunkNotEnoughData,
1516 #[error("failed to unmarshal, contains unknown chunk type")]
1518 ErrUnmarshalUnknownChunkType,
1519 #[error("checksum mismatch theirs")]
1521 ErrChecksumMismatch,
1522
1523 #[error("unexpected chunk popped (unordered)")]
1525 ErrUnexpectedChuckPoppedUnordered,
1526 #[error("unexpected chunk popped (ordered)")]
1528 ErrUnexpectedChuckPoppedOrdered,
1529 #[error("unexpected q state (should've been selected)")]
1531 ErrUnexpectedQState,
1532 #[error("try again")]
1534 ErrTryAgain,
1535
1536 #[error("abort chunk, with following errors: {0}")]
1538 ErrAbortChunk(String),
1539 #[error("shutdown called in non-Established state")]
1541 ErrShutdownNonEstablished,
1542 #[error("association closed before connecting")]
1544 ErrAssociationClosedBeforeConn,
1545 #[error("association init failed")]
1547 ErrAssociationInitFailed,
1548 #[error("association handshake closed")]
1550 ErrAssociationHandshakeClosed,
1551 #[error("silently discard")]
1553 ErrSilentlyDiscard,
1554 #[error("the init not stored to send")]
1556 ErrInitNotStoredToSend,
1557 #[error("cookieEcho not stored to send")]
1559 ErrCookieEchoNotStoredToSend,
1560 #[error("sctp packet must not have a source port of 0")]
1562 ErrSctpPacketSourcePortZero,
1563 #[error("sctp packet must not have a destination port of 0")]
1565 ErrSctpPacketDestinationPortZero,
1566 #[error("init chunk must not be bundled with any other chunk")]
1568 ErrInitChunkBundled,
1569 #[error("shutdown complete chunk must not be bundled with any other chunk")]
1572 ErrShutdownCompleteChunkBundled,
1573 #[error("init chunk expects a verification tag of 0 on the packet when out-of-the-blue")]
1575 ErrInitChunkVerifyTagNotZero,
1576 #[error("todo: handle Init when in state")]
1578 ErrHandleInitState,
1579 #[error("no cookie in InitAck")]
1581 ErrInitAckNoCookie,
1582 #[error("there already exists a stream with identifier")]
1584 ErrStreamAlreadyExist,
1585 #[error("Failed to create a stream with identifier")]
1587 ErrStreamCreateFailed,
1588 #[error("unable to be popped from inflight queue TSN")]
1590 ErrInflightQueueTsnPop,
1591 #[error("requested non-existent TSN")]
1593 ErrTsnRequestNotExist,
1594 #[error("sending reset packet in non-Established state")]
1596 ErrResetPacketInStateNotExist,
1597 #[error("unexpected parameter type")]
1599 ErrParameterType,
1600 #[error("sending payload data in non-Established state")]
1602 ErrPayloadDataStateNotExist,
1603 #[error("unhandled chunk type")]
1605 ErrChunkTypeUnhandled,
1606 #[error("handshake failed (INIT ACK)")]
1608 ErrHandshakeInitAck,
1609 #[error("handshake failed (COOKIE ECHO)")]
1611 ErrHandshakeCookieEcho,
1612
1613 #[error("outbound packet larger than maximum message size")]
1615 ErrOutboundPacketTooLarge,
1616 #[error(
1620 "a {size} byte message is over the {limit} byte limit of an SCTP association without \
1621 message interleaving (RFC 8831 section 6.6: the peer did not announce I-DATA); \
1622 SettingEngineBuilder::with_sctp_message_size_limit_without_interleaving(false) lifts it \
1623 up to the peer's max-message-size"
1624 )]
1625 ErrMessageTooLargeWithoutInterleaving {
1626 size: usize,
1628 limit: u32,
1630 },
1631 #[error("Stream closed")]
1633 ErrStreamClosed,
1634 #[error("Stream not existed")]
1636 ErrStreamNotExisted,
1637 #[error("Association not existed")]
1639 ErrAssociationNotExisted,
1640 #[error("Transport not existed")]
1642 ErrTransportNoExisted,
1643 #[error("Io EOF")]
1645 ErrEof,
1646 #[error("Invalid SystemTime")]
1648 ErrInvalidSystemTime,
1649 #[error("Net Conn read error")]
1651 ErrNetConnRead,
1652 #[error("Max Data Channel ID")]
1654 ErrMaxDataChannelID,
1655
1656 #[error(
1659 "DataChannel message is not long enough to determine type: (expected: {expected}, actual: {actual})"
1660 )]
1661 UnexpectedEndOfBuffer {
1662 expected: usize,
1664 actual: usize,
1666 },
1667 #[error("Unknown MessageType {0}")]
1669 InvalidMessageType(u8),
1670 #[error("Unknown ChannelType {0}")]
1672 InvalidChannelType(u8),
1673 #[error("Unknown PayloadProtocolIdentifier {0}")]
1675 InvalidPayloadProtocolIdentifier(u8),
1676 #[error("Unknow Protocol")]
1678 UnknownProtocol,
1679
1680 #[error("stream is nil")]
1683 ErrNilStream,
1684 #[error("incomplete frame header")]
1686 ErrIncompleteFrameHeader,
1687 #[error("incomplete frame data")]
1689 ErrIncompleteFrameData,
1690 #[error("incomplete file header")]
1692 ErrIncompleteFileHeader,
1693 #[error("IVF signature mismatch")]
1695 ErrSignatureMismatch,
1696 #[error("IVF version unknown, parser may not parse correctly")]
1698 ErrUnknownIVFVersion,
1699
1700 #[error("file not opened")]
1702 ErrFileNotOpened,
1703 #[error("invalid nil packet")]
1705 ErrInvalidNilPacket,
1706
1707 #[error("bad header signature")]
1709 ErrBadIDPageSignature,
1710 #[error("wrong header, expected beginning of stream")]
1712 ErrBadIDPageType,
1713 #[error("payload for id page must be 19 bytes")]
1715 ErrBadIDPageLength,
1716 #[error("bad payload signature")]
1718 ErrBadIDPagePayloadSignature,
1719 #[error("not enough data for payload header")]
1721 ErrShortPageHeader,
1722 #[error("bad OpusTags signature")]
1724 ErrBadOpusTagsSignature,
1725 #[error("unsupported channel mapping family")]
1727 ErrUnsupportedChannelMappingFamily,
1728
1729 #[error("data is not a H264 bitstream")]
1731 ErrDataIsNotH264Stream,
1732 #[error("data is not a H265 bitstream")]
1734 ErrDataIsNotH265Stream,
1735 #[error("Io EOF")]
1737 ErrIoEOF,
1738
1739 #[error("mDNS: port not support, only 5353 is supported")]
1742 ErrMDNSPortNotSupported,
1743 #[error("mDNS: connection is closed")]
1745 ErrMDNSConnectionClosed,
1746 #[error("mDNS: query not found")]
1748 ErrMDNSQueryNotFound,
1749 #[error("mDNS: parsing/packing of this type isn't available yet")]
1751 ErrNotStarted,
1752 #[error("mDNS: parsing/packing of this section has completed")]
1754 ErrSectionDone,
1755 #[error("mDNS: parsing/packing of this section is header")]
1757 ErrSectionHeader,
1758 #[error("mDNS: insufficient data for base length type")]
1760 ErrBaseLen,
1761 #[error("mDNS: insufficient data for calculated length type")]
1763 ErrCalcLen,
1764 #[error("mDNS: segment prefix is reserved")]
1766 ErrReserved,
1767 #[error("mDNS: too many pointers (>10)")]
1769 ErrTooManyPtr,
1770 #[error("mDNS: invalid pointer")]
1772 ErrInvalidPtr,
1773 #[error("mDNS: nil resource body")]
1775 ErrNilResourceBody,
1776 #[error("mDNS: insufficient data for resource body length")]
1778 ErrResourceLen,
1779 #[error("mDNS: segment length too long")]
1781 ErrSegTooLong,
1782 #[error("mDNS: zero length segment")]
1784 ErrZeroSegLen,
1785 #[error("mDNS: resource length too long")]
1787 ErrResTooLong,
1788 #[error("mDNS: too many Questions to pack (>65535)")]
1790 ErrTooManyQuestions,
1791 #[error("mDNS: too many Answers to pack (>65535)")]
1793 ErrTooManyAnswers,
1794 #[error("mDNS: too many Authorities to pack (>65535)")]
1796 ErrTooManyAuthorities,
1797 #[error("mDNS: too many Additionals to pack (>65535)")]
1799 ErrTooManyAdditionals,
1800 #[error("mDNS: name is not in canonical format (it must end with a .)")]
1802 ErrNonCanonicalName,
1803 #[error("mDNS: character string exceeds maximum length (255)")]
1805 ErrStringTooLong,
1806 #[error("mDNS: compressed name in SRV resource data")]
1808 ErrCompressedSrv,
1809 #[error("mDNS: empty builder msg")]
1811 ErrEmptyBuilderMsg,
1812
1813 #[error("connection closed")]
1817 ErrConnectionClosed,
1818
1819 #[error("data channel closed")]
1822 ErrDataChannelClosed,
1823
1824 #[error("data channel is not open yet")]
1828 ErrDataChannelNotOpen,
1829
1830 #[error("data channel stream identifier has not been assigned yet")]
1838 ErrDataChannelStreamIdNotAssigned,
1839
1840 #[error("data channel not existed")]
1843 ErrDataChannelNotExisted,
1844
1845 #[error("data channel send buffer full")]
1849 ErrSendBufferFull,
1850
1851 #[error("x509Cert expired")]
1853 ErrCertificateExpired,
1854
1855 #[error("an ICE server has no url")]
1858 ErrNoIceServerUrls,
1859
1860 #[error("turn server credentials required")]
1863 ErrNoTurnCredentials,
1864
1865 #[error("invalid turn server credentials")]
1868 ErrTurnCredentials,
1869
1870 #[error("track already exists")]
1872 ErrExistingTrack,
1873
1874 #[error("track not existed")]
1876 ErrTrackNotExisted,
1877
1878 #[error("private key type not supported")]
1881 ErrPrivateKeyType,
1882
1883 #[error("peerIdentity cannot be modified")]
1886 ErrModifyingPeerIdentity,
1887
1888 #[error("certificates cannot be modified")]
1891 ErrModifyingCertificates,
1892
1893 #[error("no certificate")]
1895 ErrNonCertificate,
1896
1897 #[error("bundle policy cannot be modified")]
1900 ErrModifyingBundlePolicy,
1901
1902 #[error("rtcp mux policy cannot be modified")]
1905 ErrModifyingRTCPMuxPolicy,
1906
1907 #[error("ice candidate pool size cannot be modified")]
1910 ErrModifyingICECandidatePoolSize,
1911
1912 #[error("data channel label exceeds size limit")]
1915 ErrStringSizeLimit,
1916
1917 #[error("negotiated set without channel id")]
1921 ErrNegotiatedWithoutID,
1922
1923 #[error("both max_packet_life_time and max_retransmits was set")]
1928 ErrRetransmitsOrPacketLifeTime,
1929
1930 #[error("codec not found")]
1932 ErrCodecNotFound,
1933
1934 #[error("remote description is not set")]
1937 ErrNoRemoteDescription,
1938
1939 #[error(
1942 "no media section of the remote description matches the candidate's sdpMid or sdpMLineIndex"
1943 )]
1944 ErrIceCandidateMediaSectionNotFound,
1945
1946 #[error("the candidate's usernameFragment is not its media section's ice-ufrag")]
1949 ErrIceCandidateUsernameFragmentMismatch,
1950
1951 #[error(
1955 "set_remote_description called with an ice-ufrag or ice-pwd that isn't RFC 8839 syntax"
1956 )]
1957 ErrSessionDescriptionInvalidIceCredentials,
1958
1959 #[error("offer SDP semantics does not match configuration")]
1962 ErrIncorrectSDPSemantics,
1963
1964 #[error("operation can not be run in current signaling state")]
1966 ErrIncorrectSignalingState,
1967
1968 #[error("protocol is larger then 65535 bytes")]
1971 ErrProtocolTooLarge,
1972
1973 #[error("label is larger than 65535 bytes")]
1976 ErrLabelTooLarge,
1977
1978 #[error("the {0} replay window of {1} packets is below the 64 RFC 3711 requires")]
1980 ErrSrtpReplayWindowTooSmall(&'static str, usize),
1981
1982 #[error("OperationError: {0}")]
1984 ErrOperationError(String),
1985
1986 #[error("{0:?} is not a DTMF tone")]
1988 ErrDtmfInvalidCharacter(char),
1989
1990 #[error("the data channel's send buffer is full")]
1993 ErrDataChannelBufferFull,
1994
1995 #[error("the data channel id is not below the SCTP transport's maxChannels")]
1998 ErrDataChannelIdAboveMaxChannels,
1999
2000 #[error("data channel id is already in use")]
2003 ErrDataChannelIdInUse,
2004
2005 #[error("RtpSender not created by this PeerConnection")]
2008 ErrSenderNotCreatedByConnection,
2009
2010 #[error("RtpSender's initial_track_id has already been set")]
2013 ErrSenderInitialTrackIdAlreadySet,
2014
2015 #[error("set_remote_description called with no fingerprint")]
2018 ErrSessionDescriptionNoFingerprint,
2019
2020 #[error("set_remote_description called with an invalid fingerprint")]
2023 ErrSessionDescriptionInvalidFingerprint,
2024
2025 #[error("set_remote_description called with multiple conflicting fingerprint")]
2028 ErrSessionDescriptionConflictingFingerprints,
2029
2030 #[error("set_remote_description called with an invalid setup attribute")]
2034 ErrSessionDescriptionInvalidSetup,
2035
2036 #[error("set_remote_description called with an invalid tls-id attribute")]
2040 ErrSessionDescriptionInvalidTlsId,
2041
2042 #[error("invalid identity assertion")]
2044 ErrInvalidIdentityAssertion,
2045
2046 #[error("set_remote_description called with no ice-ufrag")]
2049 ErrSessionDescriptionMissingIceUfrag,
2050
2051 #[error("set_remote_description called with no ice-pwd")]
2054 ErrSessionDescriptionMissingIcePwd,
2055
2056 #[error("set_remote_description called with multiple conflicting ice-ufrag values")]
2059 ErrSessionDescriptionConflictingIceUfrag,
2060
2061 #[error("set_remote_description called with multiple conflicting ice-pwd values")]
2064 ErrSessionDescriptionConflictingIcePwd,
2065
2066 #[error("set_remote_description called without a=cryptex while header encryption is required")]
2070 ErrSessionDescriptionMissingCryptex,
2071
2072 #[error("DTLS Handshake completed and no SRTP Protection Profile was chosen")]
2074 ErrNoSRTPProtectionProfile,
2075
2076 #[error("failed to generate certificate fingerprint")]
2078 ErrFailedToGenerateCertificateFingerprint,
2079
2080 #[error("operation failed no codecs are available")]
2082 ErrNoCodecsAvailable,
2083
2084 #[error("unable to start track, codec is not supported by remote")]
2086 ErrUnsupportedCodec,
2087
2088 #[error("Invalid state error")]
2090 InvalidStateError,
2091
2092 #[error("Invalid modification error")]
2094 InvalidModificationError,
2095
2096 #[error("Not found error")]
2099 NotFoundError,
2100
2101 #[error("Invalid access error")]
2105 InvalidAccessError,
2106
2107 #[error("Range error {0}")]
2109 RangeError(String),
2110
2111 #[error("Type error {0}")]
2113 TypeError(String),
2114
2115 #[error("Overconstrained: {0}")]
2119 OverconstrainedError(String),
2120
2121 #[error("SFrame was offered and the answer refused it: no media is sent")]
2124 ErrSFrameRefused,
2125
2126 #[error("SDP syntax error{}: {error}", .line_number.map(|n| format!(" on line {n}")).unwrap_or_default())]
2129 SdpSyntaxError {
2130 line_number: Option<usize>,
2132 error: Box<Error>,
2134 },
2135
2136 #[error("unable to populate media section, RTPSender created with no codecs")]
2139 ErrSenderWithNoCodecs,
2140
2141 #[error("unable to populate media section, RTPSender created with no ssrcs")]
2144 ErrSenderWithNoSSRCs,
2145
2146 #[error("new track must be of the same kind as previous")]
2148 ErrRTPSenderNewTrackHasIncorrectKind,
2149
2150 #[error("new track has incorrect envelope")]
2152 ErrRTPSenderNewTrackHasIncorrectEnvelope,
2153
2154 #[error("Sequence number transformer must be enabled before sending data")]
2156 ErrRTPSenderDataSent,
2157
2158 #[error("Sequence number transformer has been already enabled")]
2160 ErrRTPSenderSeqTransEnabled,
2161
2162 #[error("failed to unbind TrackLocal from PeerConnection")]
2164 ErrUnbindFailed,
2165
2166 #[error("the requested codec does not have a payloader")]
2168 ErrNoPayloaderForCodec,
2169
2170 #[error("a header extension must be registered with the same direction each time")]
2173 ErrRegisterHeaderExtensionInvalidDirection,
2174
2175 #[error("invalid direction")]
2177 ErrInvalidDirection,
2178
2179 #[error(
2183 "no header extension ID was free to use (the maximum of 254 extensions have been registered)"
2184 )]
2185 ErrRegisterHeaderExtensionNoFreeID,
2186
2187 #[error("simulcast probe limit has been reached, new SSRC has been discarded")]
2189 ErrSimulcastProbeOverflow,
2190
2191 #[error("enable detaching by calling webrtc.DetachDataChannels()")]
2193 ErrDetachNotEnabled,
2194 #[error("datachannel not opened yet, try calling Detach from OnOpen")]
2196 ErrDetachBeforeOpened,
2197 #[error("the DTLS transport has not started yet")]
2199 ErrDtlsTransportNotStarted,
2200 #[error("failed extracting keys from DTLS for SRTP")]
2202 ErrDtlsKeyExtractionFailed,
2203 #[error("failed to start SRTP")]
2205 ErrFailedToStartSRTP,
2206 #[error("failed to start SRTCP")]
2208 ErrFailedToStartSRTCP,
2209 #[error("attempted to start DTLSTransport that is not in new state")]
2211 ErrInvalidDTLSStart,
2212 #[error("peer didn't provide certificate via DTLS")]
2214 ErrNoRemoteCertificate,
2215 #[error("identity provider is not implemented")]
2217 ErrIdentityProviderNotImplemented,
2218 #[error("remote certificate does not match any fingerprint")]
2220 ErrNoMatchingCertificateFingerprint,
2221 #[error("unsupported fingerprint algorithm")]
2223 ErrUnsupportedFingerprintAlgorithm,
2224 #[error("ICE connection not started")]
2226 ErrICEConnectionNotStarted,
2227 #[error("unknown candidate type")]
2229 ErrICECandidateTypeUnknown,
2230 #[error("cannot convert ice.CandidateType into webrtc.ICECandidateType, invalid type")]
2232 ErrICEInvalidConvertCandidateType,
2233 #[error("ICEAgent does not exist")]
2235 ErrICEAgentNotExist,
2236 #[error("unable to convert ICE candidates to ICECandidates")]
2238 ErrICECandidatesConversionFailed,
2239 #[error("unknown ICE Role")]
2241 ErrICERoleUnknown,
2242 #[error("unknown protocol")]
2244 ErrICEProtocolUnknown,
2245 #[error("gatherer not started")]
2247 ErrICEGathererNotStarted,
2248 #[error("unknown network type")]
2250 ErrNetworkTypeUnknown,
2251 #[error("new sdp does not match previous offer")]
2253 ErrSDPDoesNotMatchOffer,
2254 #[error("new sdp does not match previous answer")]
2256 ErrSDPDoesNotMatchAnswer,
2257 #[error("the answer does not match the offer: {0}")]
2260 ErrAnswerDoesNotMatchOffer(String),
2261 #[error("provided value is not a valid enum value of type SDPType")]
2263 ErrPeerConnSDPTypeInvalidValue,
2264 #[error("invalid state change op")]
2266 ErrPeerConnStateChangeInvalid,
2267 #[error("unhandled state change op")]
2269 ErrPeerConnStateChangeUnhandled,
2270 #[error("invalid SDP type supplied to SetLocalDescription()")]
2272 ErrPeerConnSDPTypeInvalidValueSetLocalDescription,
2273 #[error("remoteDescription contained media section without mid value")]
2275 ErrPeerConnRemoteDescriptionWithoutMidValue,
2276 #[error("localDescription contained media section without mid value")]
2278 ErrPeerConnLocalDescriptionWithoutMidValue,
2279 #[error("remoteDescription has not been set yet")]
2281 ErrPeerConnRemoteDescriptionNil,
2282 #[error("localDescription has not been set yet")]
2284 ErrPeerConnLocalDescriptionNil,
2285 #[error("single media section has an explicit SSRC")]
2287 ErrPeerConnSingleMediaSectionHasExplicitSSRC,
2288 #[error("could not add transceiver for remote SSRC")]
2290 ErrPeerConnRemoteSSRCAddTransceiver,
2291 #[error("mid RTP Extensions required for Simulcast")]
2293 ErrPeerConnSimulcastMidRTPExtensionRequired,
2294 #[error("stream id RTP Extensions required for Simulcast")]
2296 ErrPeerConnSimulcastStreamIDRTPExtensionRequired,
2297 #[error("incoming SSRC failed Simulcast probing")]
2299 ErrPeerConnSimulcastIncomingSSRCFailed,
2300 #[error("failed collecting stats")]
2302 ErrPeerConnStatsCollectionFailed,
2303 #[error("add_transceiver_from_kind only accepts one RTPTransceiverInit")]
2305 ErrPeerConnAddTransceiverFromKindOnlyAcceptsOne,
2306 #[error("add_transceiver_from_track only accepts one RTPTransceiverInit")]
2308 ErrPeerConnAddTransceiverFromTrackOnlyAcceptsOne,
2309 #[error("add_transceiver_from_kind currently only supports recvonly")]
2311 ErrPeerConnAddTransceiverFromKindSupport,
2312 #[error("add_transceiver_from_track currently only supports sendonly and sendrecv")]
2314 ErrPeerConnAddTransceiverFromTrackSupport,
2315 #[error("TODO set_identity_provider")]
2317 ErrPeerConnSetIdentityProviderNotImplemented,
2318 #[error("write_rtcp failed to open write_stream")]
2320 ErrPeerConnWriteRTCPOpenWriteStream,
2321 #[error("cannot find transceiver with mid")]
2323 ErrPeerConnTransceiverMidNil,
2324 #[error("DTLSTransport must not be nil")]
2326 ErrRTPReceiverDTLSTransportNil,
2327 #[error("Receive has already been called")]
2329 ErrRTPReceiverReceiveAlreadyCalled,
2330 #[error("unable to find stream for Track with SSRC")]
2332 ErrRTPReceiverWithSSRCTrackStreamNotFound,
2333 #[error("no trackStreams found for SSRC")]
2335 ErrRTPReceiverForSSRCTrackStreamNotFound,
2336 #[error("no trackStreams found for RID")]
2338 ErrRTPReceiverForRIDTrackStreamNotFound,
2339 #[error("invalid RTP Receiver transition")]
2341 ErrRTPReceiverStateChangeInvalid,
2342 #[error("Track must not be nil")]
2344 ErrRTPSenderTrackNil,
2345 #[error("RTPSender not existed")]
2347 ErrRTPSenderNotExisted,
2348 #[error("Sender Track has been removed or replaced to nil")]
2350 ErrRTPSenderTrackRemoved,
2351 #[error("Sender cannot add encoding as rid is empty")]
2353 ErrRTPSenderRidNil,
2354 #[error("no a=imageattr line of the remote description can be satisfied")]
2358 ErrImageAttrUnsatisfiable,
2359 #[error("Sender cannot add encoding as there is no base track")]
2361 ErrRTPSenderNoBaseEncoding,
2362 #[error("Sender cannot add encoding as provided track does not match base track")]
2364 ErrRTPSenderBaseEncodingMismatch,
2365 #[error("Sender cannot encoding due to RID collision")]
2367 ErrRTPSenderRIDCollision,
2368 #[error("sender encodings name SSRC {0} for more than one stream")]
2372 ErrRTPSenderSsrcCollision(u32),
2373 #[error("RTCP feedback `{0} {1}` was not negotiated for the stream")]
2376 ErrRTCPFeedbackNotNegotiated(String, String),
2377 #[error("Sender cannot add encoding as its rid is not 1 to 255 alphanumeric characters")]
2380 ErrRTPSenderRidInvalid,
2381 #[error("Sender cannot use SSRC {0}: another local stream has it")]
2385 ErrRTPSenderSsrcTaken(u32),
2386 #[error("the remote description carries no identity assertion")]
2389 ErrNoRemoteIdentityAssertion,
2390 #[error("the verified identity does not cover every fingerprint of the remote description")]
2393 ErrIdentityFingerprintsNotCovered,
2394 #[error("the certificate in use is not among the fingerprints of the verified identity")]
2397 ErrIdentityCertificateNotCovered,
2398 #[error("Sender does not have track for RID")]
2400 ErrRTPSenderNoTrackForRID,
2401 #[error("RTPReceiver not existed")]
2403 ErrRTPReceiverNotExisted,
2404 #[error("DTLSTransport must not be nil")]
2406 ErrRTPSenderDTLSTransportNil,
2407 #[error("Send has already been called")]
2409 ErrRTPSenderSendAlreadyCalled,
2410 #[error("RTPTransceiver not existed")]
2412 ErrRTPTransceiverNotExisted,
2413 #[error("SCTPTransport not existed")]
2415 ErrSCTPTransportNotExisted,
2416 #[error("DTLSTransport not existed")]
2418 ErrDTLSTransportNotExisted,
2419 #[error("errRTPSenderTrackNil")]
2421 ErrRTPTransceiverCannotChangeMid,
2422 #[error("invalid state change in RTPTransceiver.setSending")]
2424 ErrRTPTransceiverSetSendingInvalidState,
2425 #[error("unsupported codec type by this transceiver")]
2427 ErrRTPTransceiverCodecUnsupported,
2428 #[error("DTLS not established")]
2430 ErrSCTPTransportDTLS,
2431 #[error("add_transceiver_sdp() called with 0 transceivers")]
2433 ErrSDPZeroTransceivers,
2434 #[error("invalid Media Section. Data channel section without a valid a=sctp-port")]
2436 ErrSDPSctpPortInvalid,
2437 #[error("invalid Media Section. Media + DataChannel both enabled")]
2439 ErrSDPMediaSectionMediaDataChanInvalid,
2440 #[error("invalid Media Section Track Index")]
2442 ErrSDPMediaSectionTrackInvalid,
2443 #[error("can't rollback from stable state")]
2445 ErrSignalingStateCannotRollback,
2446 #[error("invalid proposed signaling state transition: {0}")]
2448 ErrSignalingStateProposedTransitionInvalid(String),
2449 #[error("cannot convert to StatsICECandidatePairStateSucceeded invalid ice candidate state")]
2451 ErrStatsICECandidateStateInvalid,
2452 #[error("ICETransport can only be called in ICETransportStateNew")]
2454 ErrICETransportNotInNew,
2455 #[error(
2458 "local candidate on {0}, a transport address of the previous DTLS association: a new DTLS association needs a new local address or port (RFC 8842 section 5.1)"
2459 )]
2460 ErrICECandidateAddressOfPreviousDtlsAssociation(std::net::SocketAddr),
2461 #[error("bad Certificate PEM format")]
2463 ErrCertificatePEMFormatError,
2464 #[error("SCTP is not established")]
2466 ErrSCTPNotEstablished,
2467
2468 #[error("DataChannel is not opened")]
2470 ErrClosedPipe,
2471 #[error("Interceptor is not bind")]
2473 ErrInterceptorNotBind,
2474 #[error("excessive retries in CreateOffer")]
2476 ErrExcessiveRetries,
2477
2478 #[error("not long enough to be a RTP Packet")]
2480 ErrRTPTooShort,
2481
2482 #[error("RFC8851 mandates rid-syntax = %s\"a=rid:\" rid-id SP rid-dir")]
2484 SimulcastRidParseErrorSyntaxIdDirSplit,
2485 #[error("RFC8851 mandates rid-dir = %s\"send\" / %s\"recv\"")]
2487 SimulcastRidParseErrorUnknownDirection,
2488
2489 #[error("codec not found")]
2492 CodecNotFound,
2493 #[error("missing whitespace")]
2495 MissingWhitespace,
2496 #[error("missing colon")]
2498 MissingColon,
2499 #[error("payload type not found")]
2501 PayloadTypeNotFound,
2502 #[error("SdpInvalidSyntax: {0}")]
2504 SdpInvalidSyntax(String),
2505 #[error("SdpInvalidValue: {0}")]
2507 SdpInvalidValue(String),
2508 #[error("sdp: empty time_descriptions")]
2510 SdpEmptyTimeDescription,
2511 #[error("parse extmap: {0}")]
2513 ParseExtMap(String),
2514 #[error("{} --> {} <-- {}", .s.substring(0,*.p), .s.substring(*.p, *.p+1), .s.substring(*.p+1, .s.len())
2516 )]
2517 SyntaxError {
2518 s: String,
2520 p: usize,
2522 },
2523
2524 #[error("invalid PEM: {0}")]
2527 InvalidPEM(String),
2528 #[error("parse ip: {0}")]
2530 ParseIp(#[from] net::AddrParseError),
2531 #[error("parse int: {0}")]
2533 ParseInt(#[from] ParseIntError),
2534 #[error("{0}")]
2536 Io(#[source] IoError),
2537 #[error("url parse: {0}")]
2539 Url(#[from] url::ParseError),
2540 #[error("utf8: {0}")]
2542 Utf8(#[from] FromUtf8Error),
2543 #[error("{0}")]
2545 Std(#[source] StdError),
2546 #[error("Other RTCP Err: {0}")]
2549 OtherRtcpErr(String),
2550 #[error("Other RTP Err: {0}")]
2552 OtherRtpErr(String),
2553 #[error("Other SRTP Err: {0}")]
2555 OtherSrtpErr(String),
2556 #[error("Other STUN Err: {0}")]
2558 OtherStunErr(String),
2559 #[error("Other TURN Err: {0}")]
2561 OtherTurnErr(String),
2562 #[error("Other ICE Err: {0}")]
2564 OtherIceErr(String),
2565 #[error("Other DTLS Err: {0}")]
2567 OtherDtlsErr(String),
2568 #[error("Other SCTP Err: {0}")]
2570 OtherSctpErr(String),
2571 #[error("Other DataChannel Err: {0}")]
2573 OtherDataChannelErr(String),
2574 #[error("Other Interceptor Err: {0}")]
2576 OtherInterceptorErr(String),
2577 #[error("Other Media Err: {0}")]
2579 OtherMediaErr(String),
2580 #[error("Other mDNS Err: {0}")]
2582 OtherMdnsErr(String),
2583 #[error("Other SDP Err: {0}")]
2585 OtherSdpErr(String),
2586 #[error("Other PeerConnection Err: {0}")]
2588 OtherPeerConnectionErr(String),
2589 #[error("crypto: {0}")]
2591 Crypto(String),
2592 #[error("stream: unknown connection or listener")]
2595 ErrUnknownStream,
2596 #[error("stream: connection closed")]
2598 ErrStreamConnectionClosed,
2599 #[error("stream: message too long for its framing")]
2602 ErrStreamMessageTooLong,
2603 #[error("{0}")]
2604 Other(String),
2606}
2607
2608impl Error {
2609 pub fn from_std<T>(error: T) -> Self
2612 where
2613 T: std::error::Error + Send + Sync + 'static,
2614 {
2615 Error::Std(StdError(Box::new(error)))
2616 }
2617
2618 pub fn dom_exception_name(&self) -> Option<&'static str> {
2650 match self {
2651 Error::SdpSyntaxError { .. } | Error::SdpInvalidSyntax(_) => Some("OperationError"),
2652 Error::ErrIceCandidateMediaSectionNotFound
2653 | Error::ErrIceCandidateUsernameFragmentMismatch => Some("OperationError"),
2654 Error::ErrNoIceServerUrls
2655 | Error::ErrSchemeType
2656 | Error::ErrInvalidUrl
2657 | Error::ErrStunQuery
2658 | Error::ErrInvalidQuery
2659 | Error::ErrProtoType => Some("SyntaxError"),
2660 Error::ErrSDPDoesNotMatchOffer
2661 | Error::ErrSDPDoesNotMatchAnswer
2662 | Error::ErrModifyingCertificates
2663 | Error::ErrModifyingBundlePolicy
2664 | Error::ErrModifyingRTCPMuxPolicy
2665 | Error::ErrModifyingICECandidatePoolSize => Some("InvalidModificationError"),
2666 Error::ErrCertificateExpired | Error::ErrNoTurnCredentials => {
2667 Some("InvalidAccessError")
2668 }
2669 Error::ErrNoRemoteDescription => Some("InvalidStateError"),
2670 Error::InvalidAccessError
2671 | Error::SdpInvalidValue(_)
2672 | Error::ErrPeerConnRemoteDescriptionWithoutMidValue
2673 | Error::ErrSessionDescriptionInvalidIceCredentials
2674 | Error::ErrSessionDescriptionNoFingerprint
2675 | Error::ErrSessionDescriptionInvalidFingerprint
2676 | Error::ErrSessionDescriptionConflictingFingerprints
2677 | Error::ErrSessionDescriptionInvalidSetup
2678 | Error::ErrSessionDescriptionInvalidTlsId
2679 | Error::ErrSessionDescriptionMissingIceUfrag
2680 | Error::ErrSessionDescriptionMissingIcePwd
2681 | Error::ErrSessionDescriptionConflictingIceUfrag
2682 | Error::ErrSessionDescriptionConflictingIcePwd
2683 | Error::ErrSessionDescriptionMissingCryptex => Some("InvalidAccessError"),
2684 Error::InvalidStateError
2685 | Error::ErrConnectionClosed
2686 | Error::ErrIncorrectSignalingState
2687 | Error::ErrSignalingStateCannotRollback
2688 | Error::ErrSignalingStateProposedTransitionInvalid(_) => Some("InvalidStateError"),
2689 Error::InvalidModificationError => Some("InvalidModificationError"),
2690 Error::NotFoundError => Some("NotFoundError"),
2691 Error::RangeError(_) => Some("RangeError"),
2692 Error::TypeError(_) => Some("TypeError"),
2693 Error::OverconstrainedError(_) => Some("OverconstrainedError"),
2694 _ => None,
2695 }
2696 }
2697
2698 pub fn rtc_error_detail(&self) -> Option<&'static str> {
2701 match self {
2702 Error::SdpSyntaxError { .. } | Error::SdpInvalidSyntax(_) => Some("sdp-syntax-error"),
2703 _ => None,
2704 }
2705 }
2706
2707 pub fn downcast_ref<T: std::error::Error + 'static>(&self) -> Option<&T> {
2712 if let Error::Std(s) = self {
2713 return s.0.downcast_ref();
2714 }
2715
2716 None
2717 }
2718}
2719
2720#[derive(Debug, Error)]
2726#[error("io error: {0}")]
2727pub struct IoError(#[from] pub io::Error);
2728
2729impl PartialEq for IoError {
2731 fn eq(&self, other: &Self) -> bool {
2732 self.0.kind() == other.0.kind()
2733 }
2734}
2735
2736impl From<io::Error> for Error {
2737 fn from(e: io::Error) -> Self {
2738 Error::Io(IoError(e))
2739 }
2740}
2741
2742#[derive(Debug, Error)]
2752#[error("{0}")]
2753pub struct StdError(pub Box<dyn std::error::Error + Send + Sync>);
2754
2755impl PartialEq for StdError {
2756 fn eq(&self, _: &Self) -> bool {
2757 false
2758 }
2759}
2760
2761impl<T> From<std::sync::PoisonError<T>> for Error {
2762 fn from(e: std::sync::PoisonError<T>) -> Self {
2763 Error::PoisonError(e.to_string())
2764 }
2765}
2766
2767impl From<SystemTimeError> for Error {
2768 fn from(e: SystemTimeError) -> Self {
2769 Error::Other(e.to_string())
2770 }
2771}
2772
2773pub fn flatten_errs(errs: Vec<impl Into<Error>>) -> Result<()> {
2777 if errs.is_empty() {
2778 Ok(())
2779 } else {
2780 let errs_strs: Vec<String> = errs.into_iter().map(|e| e.into().to_string()).collect();
2781 Err(Error::Other(errs_strs.join("\n")))
2782 }
2783}