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("export_keying_material hash: {0}")]
190 Hash(String),
191 #[error("mutex poison: {0}")]
193 PoisonError(String),
194
195 #[error("Wrong marshal size")]
198 WrongMarshalSize,
199 #[error("Invalid total lost count")]
202 InvalidTotalLost,
203 #[error("Invalid header")]
205 InvalidHeader,
206 #[error("Empty compound packet")]
208 EmptyCompound,
209 #[error("First packet in compound must be SR or RR")]
212 BadFirstPacket,
213 #[error("Compound missing SourceDescription with CNAME")]
215 MissingCname,
216 #[error("Feedback packet seen before CNAME")]
218 PacketBeforeCname,
219 #[error("Too many reports")]
221 TooManyReports,
222 #[error("Too many chunks")]
224 TooManyChunks,
225 #[error("too many sources")]
227 TooManySources,
228 #[error("Packet too short to be read")]
230 PacketTooShort,
231 #[error("Buffer too short to be written")]
233 BufferTooShort,
234 #[error("Wrong packet type")]
236 WrongType,
237 #[error("SDES must be < 255 octets long")]
239 SdesTextTooLong,
240 #[error("SDES item missing type")]
242 SdesMissingType,
243 #[error("Reason must be < 255 octets long")]
245 ReasonTooLong,
246 #[error("Invalid packet version")]
248 BadVersion,
249 #[error("Invalid padding value")]
251 WrongPadding,
252 #[error("Wrong feedback message type")]
254 WrongFeedbackType,
255 #[error("Wrong payload type")]
257 WrongPayloadType,
258 #[error("Header length is too small")]
260 HeaderTooSmall,
261 #[error("Media SSRC must be 0")]
263 SsrcMustBeZero,
264 #[error("Missing REMB identifier")]
266 MissingRembIdentifier,
267 #[error("SSRC num and length do not match")]
269 SsrcNumAndLengthMismatch,
270 #[error("Invalid size or startIndex")]
272 InvalidSizeOrStartIndex,
273 #[error("Delta exceed limit")]
275 DeltaExceedLimit,
276 #[error("Packet status chunk must be 2 bytes")]
278 PacketStatusChunkLength,
279 #[error("Invalid bitrate")]
281 InvalidBitrate,
282 #[error("Wrong chunk type")]
284 WrongChunkType,
285 #[error("Struct contains unexpected member type")]
287 BadStructMemberType,
288 #[error("Cannot read into non-pointer")]
290 BadReadParameter,
291 #[error("Invalid block size")]
293 InvalidBlockSize,
294
295 #[error("RTP header size insufficient")]
298 ErrHeaderSizeInsufficient,
299 #[error("RTP header size insufficient for extension")]
301 ErrHeaderSizeInsufficientForExtension,
302 #[error("buffer too small")]
304 ErrBufferTooSmall,
305 #[error("extension not enabled")]
307 ErrHeaderExtensionsNotEnabled,
308 #[error("extension not found")]
310 ErrHeaderExtensionNotFound,
311
312 #[error("header extension id must be between 1 and 14 for RFC 5285 extensions")]
314 ErrRfc8285oneByteHeaderIdrange,
315 #[error("header extension payload must be 16bytes or less for RFC 5285 one byte extensions")]
317 ErrRfc8285oneByteHeaderSize,
318
319 #[error("header extension id must be between 1 and 255 for RFC 5285 extensions")]
321 ErrRfc8285twoByteHeaderIdrange,
322 #[error("header extension payload must be 255bytes or less for RFC 5285 two byte extensions")]
324 ErrRfc8285twoByteHeaderSize,
325
326 #[error("header extension id must be 0 for none RFC 5285 extensions")]
328 ErrRfc3550headerIdrange,
329
330 #[error("packet is not large enough")]
332 ErrShortPacket,
333 #[error("invalid nil packet")]
335 ErrNilPacket,
336 #[error("too many PDiff")]
338 ErrTooManyPDiff,
339 #[error("too many spatial layers")]
341 ErrTooManySpatialLayers,
342 #[error("NALU Type is unhandled")]
344 ErrUnhandledNaluType,
345
346 #[error("corrupted h265 packet")]
348 ErrH265CorruptedPacket,
349 #[error("invalid h265 packet type")]
351 ErrInvalidH265PacketType,
352
353 #[error("payload is too small for OBU extension header")]
355 ErrPayloadTooSmallForObuExtensionHeader,
356 #[error("payload is too small for OBU payload size")]
358 ErrPayloadTooSmallForObuPayloadSize,
359
360 #[error("extension_payload must be in 32-bit words")]
362 HeaderExtensionPayloadNot32BitWords,
363 #[error("too many CSRCs: {0} exceeds the 4-bit CC field maximum of 15")]
365 TooManyCSRCs(usize),
366 #[error(
368 "one-byte header extension payload length {0} is outside the RFC 8285 valid range of 1-16 bytes"
369 )]
370 OneByteHeaderExtensionPayloadOutOfRange(usize),
371 #[error(
373 "two-byte header extension payload length {0} exceeds the RFC 8285 maximum of 255 bytes"
374 )]
375 TwoByteHeaderExtensionPayloadTooLarge(usize),
376 #[error("total extension payload length {0} exceeds u16::MAX (65535 bytes)")]
378 ExtensionPayloadTotalOverflow(usize),
379 #[error("NALU length {0} exceeds u16::MAX (65535 bytes)")]
381 NaluTooLarge(usize),
382 #[error("audio level overflow")]
384 AudioLevelOverflow,
385 #[error("playout delay overflow")]
387 PlayoutDelayOverflow,
388 #[error("payload is not large enough")]
390 PayloadIsNotLargeEnough,
391 #[error("STAP-A declared size({0}) is larger than buffer({1})")]
393 StapASizeLargerThanBuffer(usize, usize),
394 #[error("nalu type {0} is currently not handled")]
396 NaluTypeIsNotHandled(u8),
397
398 #[error("duplicated packet")]
401 ErrDuplicated,
402 #[error("SRTP master key is not long enough")]
404 ErrShortSrtpMasterKey,
405 #[error("SRTP master salt is not long enough")]
407 ErrShortSrtpMasterSalt,
408 #[error("no such SRTP Profile")]
410 ErrNoSuchSrtpProfile,
411 #[error("indexOverKdr > 0 is not supported yet")]
413 ErrNonZeroKdrNotSupported,
414 #[error("exporter called with wrong label")]
416 ErrExporterWrongLabel,
417 #[error("no config provided")]
419 ErrNoConfig,
420 #[error("no conn provided")]
422 ErrNoConn,
423 #[error("failed to verify auth tag")]
425 ErrFailedToVerifyAuthTag,
426 #[error("packet is too short to be RTP packet")]
428 ErrTooShortRtp,
429 #[error("packet is too short to be RTCP packet")]
431 ErrTooShortRtcp,
432 #[error("payload differs")]
434 ErrPayloadDiffers,
435 #[error("started channel used incorrectly, should only be closed")]
437 ErrStartedChannelUsedIncorrectly,
438 #[error("stream has not been inited, unable to close")]
440 ErrStreamNotInited,
441 #[error("stream is already closed")]
443 ErrStreamAlreadyClosed,
444 #[error("stream is already inited")]
446 ErrStreamAlreadyInited,
447 #[error("failed to cast child")]
449 ErrFailedTypeAssertion,
450 #[error("exceeded the maximum number of packets")]
452 ErrExceededMaxPackets,
453
454 #[error("index_over_kdr > 0 is not supported yet")]
456 UnsupportedIndexOverKdr,
457 #[error("invalid master key length for aes_256_cm")]
459 InvalidMasterKeyLength,
460 #[error("invalid master salt length for aes_256_cm")]
462 InvalidMasterSaltLength,
463 #[error("out_len > 32 is not supported for aes_256_cm")]
465 UnsupportedOutLength,
466 #[error("SRTP Master Key must be len {0}, got {1}")]
468 SrtpMasterKeyLength(usize, usize),
469 #[error("SRTP Salt must be len {0}, got {1}")]
471 SrtpSaltLength(usize, usize),
472 #[error("SyntaxError: {0}")]
474 ExtMapParse(String),
475 #[error("ssrc {0} not exist in srtp_ssrc_state")]
477 SsrcMissingFromSrtp(u32),
478 #[error("srtp ssrc={0} index={1}: duplicated")]
480 SrtpSsrcDuplicated(u32, u16),
481 #[error("srtp ssrc={0} seq={1}: packet index already used for encryption")]
483 SrtpIndexReused(u32, u16),
484 #[error("srtp ssrc={0}: refused, the context already tracks {1} SSRCs")]
486 SrtpTooManySsrcs(u32, usize),
487 #[error("srtcp ssrc={0} index={1}: duplicated")]
489 SrtcpSsrcDuplicated(u32, usize),
490 #[error("ssrc {0} not exist in srtcp_ssrc_state")]
492 SsrcMissingFromSrtcp(u32),
493 #[error("Stream with ssrc {0} exists")]
495 StreamWithSsrcExists(u32),
496 #[error("Session RTP/RTCP type must be same as input buffer")]
498 SessionRtpRtcpTypeMismatch,
499 #[error("Session EOF")]
501 SessionEof,
502 #[error("too short SRTP packet: only {0} bytes, expected > {1} bytes")]
504 SrtpTooSmall(usize, usize),
505 #[error("too short SRTCP packet: only {0} bytes, expected > {1} bytes")]
507 SrtcpTooSmall(usize, usize),
508 #[error("failed to verify rtp auth tag")]
510 RtpFailedToVerifyAuthTag,
511 #[error("too short auth tag: only {0} bytes, expected > {1} bytes")]
513 RtcpInvalidLengthAuthTag(usize, usize),
514 #[error("failed to verify rtcp auth tag")]
516 RtcpFailedToVerifyAuthTag,
517 #[error("SessionSRTP has been closed")]
519 SessionSrtpAlreadyClosed,
520 #[error("this stream is not a RTPStream")]
522 InvalidRtpStream,
523 #[error("this stream is not a RTCPStream")]
525 InvalidRtcpStream,
526
527 #[error("attribute not found")]
530 ErrAttributeNotFound,
531 #[error("transaction is stopped")]
533 ErrTransactionStopped,
534 #[error("transaction not exists")]
536 ErrTransactionNotExists,
537 #[error("transaction exists with same id")]
539 ErrTransactionExists,
540 #[error("agent is closed")]
542 ErrAgentClosed,
543 #[error("transaction is timed out")]
545 ErrTransactionTimeOut,
546 #[error("no default reason for ErrorCode")]
548 ErrNoDefaultReason,
549 #[error("unexpected EOF")]
551 ErrUnexpectedEof,
552 #[error("attribute size is invalid")]
554 ErrAttributeSizeInvalid,
555 #[error("attribute size overflow")]
557 ErrAttributeSizeOverflow,
558 #[error("attempt to decode to nil message")]
560 ErrDecodeToNil,
561 #[error("unexpected EOF: not enough bytes to read header")]
563 ErrUnexpectedHeaderEof,
564 #[error("integrity check failed")]
566 ErrIntegrityMismatch,
567 #[error("fingerprint check failed")]
569 ErrFingerprintMismatch,
570 #[error("FINGERPRINT before MESSAGE-INTEGRITY attribute")]
572 ErrFingerprintBeforeIntegrity,
573 #[error("bad UNKNOWN-ATTRIBUTES size")]
575 ErrBadUnknownAttrsSize,
576 #[error("invalid length of IP value")]
578 ErrBadIpLength,
579 #[error("no connection provided")]
581 ErrNoConnection,
582 #[error("client is closed")]
584 ErrClientClosed,
585 #[error("no agent is set")]
587 ErrNoAgent,
588 #[error("collector is closed")]
590 ErrCollectorClosed,
591 #[error("unsupported network")]
593 ErrUnsupportedNetwork,
594 #[error("invalid url")]
596 ErrInvalidUrl,
597 #[error("unknown scheme type")]
599 ErrSchemeType,
600 #[error("invalid hostname")]
602 ErrHost,
603
604 #[error("turn: RelayAddress must be valid IP to use RelayAddressGeneratorStatic")]
607 ErrRelayAddressInvalid,
608 #[error("turn: PacketConnConfigs and ConnConfigs are empty, unable to proceed")]
610 ErrNoAvailableConns,
611 #[error("turn: PacketConnConfig must have a non-nil Conn")]
613 ErrConnUnset,
614 #[error("turn: ListenerConfig must have a non-nil Listener")]
616 ErrListenerUnset,
617 #[error("turn: RelayAddressGenerator has invalid ListeningAddress")]
619 ErrListeningAddressInvalid,
620 #[error("turn: RelayAddressGenerator in RelayConfig is unset")]
622 ErrRelayAddressGeneratorUnset,
623 #[error("turn: max retries exceeded")]
625 ErrMaxRetriesExceeded,
626 #[error("turn: MaxPort must be not 0")]
628 ErrMaxPortNotZero,
629 #[error("turn: MaxPort must be not 0")]
631 ErrMinPortNotZero,
632 #[error("turn: MaxPort less than MinPort")]
634 ErrMaxPortLessThanMinPort,
635 #[error("turn: relay_conn cannot not be nil")]
637 ErrNilConn,
638 #[error("turn: TODO")]
640 ErrTodo,
641 #[error("turn: already listening")]
643 ErrAlreadyListening,
644 #[error("turn: Server failed to close")]
646 ErrFailedToClose,
647 #[error("turn: failed to retransmit transaction")]
649 ErrFailedToRetransmitTransaction,
650 #[error("all retransmissions failed")]
652 ErrAllRetransmissionsFailed,
653 #[error("no binding found for channel")]
655 ErrChannelBindNotFound,
656 #[error("STUN server address is not set for the client")]
658 ErrStunserverAddressNotSet,
659 #[error("only one Allocate() caller is allowed")]
661 ErrOneAllocateOnly,
662 #[error("already allocated")]
664 ErrAlreadyAllocated,
665 #[error("non-STUN message from STUN server")]
667 ErrNonStunmessage,
668 #[error("failed to decode STUN message")]
670 ErrFailedToDecodeStun,
671 #[error("unexpected STUN request message")]
673 ErrUnexpectedStunrequestMessage,
674 #[error("channel number not in [0x4000, 0x7FFF]")]
676 ErrInvalidChannelNumber,
677 #[error("channelData length != len(Data)")]
679 ErrBadChannelDataLength,
680 #[error("invalid value for requested family attribute")]
682 ErrInvalidRequestedFamilyValue,
683 #[error("fake error")]
685 ErrFakeErr,
686 #[error("use of closed network connection")]
688 ErrClosed,
689 #[error("addr is not a net.UDPAddr")]
691 ErrUdpaddrCast,
692 #[error("try-lock is already locked")]
694 ErrDoubleLock,
695 #[error("transaction closed")]
697 ErrTransactionClosed,
698 #[error("wait_for_result called on non-result transaction")]
700 ErrWaitForResultOnNonResultTransaction,
701 #[error("failed to build refresh request")]
703 ErrFailedToBuildRefreshRequest,
704 #[error("failed to refresh allocation")]
706 ErrFailedToRefreshAllocation,
707 #[error("failed to get lifetime from refresh response")]
709 ErrFailedToGetLifetime,
710 #[error("too short buffer")]
712 ErrShortBuffer,
713 #[error("unexpected response type")]
715 ErrUnexpectedResponse,
716 #[error("AllocatePacketConn must be set")]
718 ErrAllocatePacketConnMustBeSet,
719 #[error("AllocateConn must be set")]
721 ErrAllocateConnMustBeSet,
722 #[error("LeveledLogger must be set")]
724 ErrLeveledLoggerMustBeSet,
725 #[error("you cannot use the same channel number with different peer")]
727 ErrSameChannelDifferentPeer,
728 #[error("allocations must not be created with nil FivTuple")]
730 ErrNilFiveTuple,
731 #[error("allocations must not be created with nil FiveTuple.src_addr")]
733 ErrNilFiveTupleSrcAddr,
734 #[error("allocations must not be created with nil FiveTuple.dst_addr")]
736 ErrNilFiveTupleDstAddr,
737 #[error("allocations must not be created with nil turnSocket")]
739 ErrNilTurnSocket,
740 #[error("allocations must not be created with a lifetime of 0")]
742 ErrLifetimeZero,
743 #[error("allocation attempt created with duplicate FiveTuple")]
745 ErrDupeFiveTuple,
746 #[error("failed to cast net.Addr to *net.UDPAddr")]
748 ErrFailedToCastUdpaddr,
749 #[error("failed to generate nonce")]
751 ErrFailedToGenerateNonce,
752 #[error("failed to send error message")]
754 ErrFailedToSendError,
755 #[error("duplicated Nonce generated, discarding request")]
757 ErrDuplicatedNonce,
758 #[error("no such user exists")]
760 ErrNoSuchUser,
761 #[error("unexpected class")]
763 ErrUnexpectedClass,
764 #[error("unexpected method")]
766 ErrUnexpectedMethod,
767 #[error("failed to handle")]
769 ErrFailedToHandle,
770 #[error("unhandled STUN packet")]
772 ErrUnhandledStunpacket,
773 #[error("unable to handle ChannelData")]
775 ErrUnableToHandleChannelData,
776 #[error("failed to create stun message from packet")]
778 ErrFailedToCreateStunpacket,
779 #[error("failed to create channel data from packet")]
781 ErrFailedToCreateChannelData,
782 #[error("relay already allocated for 5-TUPLE")]
784 ErrRelayAlreadyAllocatedForFiveTuple,
785 #[error("RequestedTransport must be UDP")]
787 ErrRequestedTransportMustBeUdp,
788 #[error("no support for DONT-FRAGMENT")]
790 ErrNoDontFragmentSupport,
791 #[error("Request must not contain RESERVATION-TOKEN and EVEN-PORT")]
793 ErrRequestWithReservationTokenAndEvenPort,
794 #[error("no allocation found")]
796 ErrNoAllocationFound,
797 #[error("unable to handle send-indication, no permission added")]
799 ErrNoPermission,
800 #[error("packet write smaller than packet")]
802 ErrShortWrite,
803 #[error("no such channel bind")]
805 ErrNoSuchChannelBind,
806 #[error("failed writing to socket")]
808 ErrFailedWriteSocket,
809
810 #[error("Unknown type")]
813 ErrUnknownType,
814
815 #[error("queries not supported in stun address")]
817 ErrStunQuery,
818
819 #[error("invalid query")]
821 ErrInvalidQuery,
822
823 #[error("url parse: invalid port number")]
825 ErrPort,
826
827 #[error("local username fragment is less than 24 bits long")]
830 ErrLocalUfragInsufficientBits,
831
832 #[error("local password is less than 128 bits long")]
835 ErrLocalPwdInsufficientBits,
836
837 #[error("local username fragment is longer than 32 characters or not made of ice-chars")]
840 ErrLocalUfragInvalid,
841
842 #[error("local password is longer than 256 characters or not made of ice-chars")]
845 ErrLocalPwdInvalid,
846
847 #[error("a local srflx, prflx or relay candidate has no related address")]
850 ErrLocalCandidateWithoutRelatedAddress,
851
852 #[error("invalid transport protocol type")]
854 ErrProtoType,
855
856 #[error("no candidate pairs available")]
858 ErrNoCandidatePairs,
859
860 #[error("connecting canceled by caller")]
862 ErrCanceledByCaller,
863
864 #[error("attempted to start agent twice")]
866 ErrMultipleStart,
867
868 #[error("remote ufrag is empty")]
870 ErrRemoteUfragEmpty,
871
872 #[error("remote pwd is empty")]
874 ErrRemotePwdEmpty,
875
876 #[error("no on_candidate provided")]
878 ErrNoOnCandidateHandler,
879
880 #[error("attempting to gather candidates during gathering state")]
882 ErrMultipleGatherAttempted,
883
884 #[error("username is empty")]
886 ErrUsernameEmpty,
887
888 #[error("password is empty")]
890 ErrPasswordEmpty,
891
892 #[error("failed to parse address")]
894 ErrAddressParseFailed,
895
896 #[error("lite agents must only use host candidates")]
898 ErrLiteUsingNonHostCandidates,
899
900 #[error("lite support only")]
902 ErrLiteSupportOnly,
903
904 #[error("agent does not need URL with selected candidate types")]
906 ErrUselessUrlsProvided,
907
908 #[error("unsupported 1:1 NAT IP candidate type")]
910 ErrUnsupportedNat1to1IpCandidateType,
911
912 #[error("invalid 1:1 NAT IP mapping")]
914 ErrInvalidNat1to1IpMapping,
915
916 #[error("external mapped IP not found")]
918 ErrExternalMappedIpNotFound,
919
920 #[error("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate")]
923 ErrMulticastDnsWithNat1to1IpMapping,
924
925 #[error("1:1 NAT IP mapping for host candidate ineffective")]
928 ErrIneffectiveNat1to1IpMappingHost,
929
930 #[error("1:1 NAT IP mapping for srflx candidate ineffective")]
933 ErrIneffectiveNat1to1IpMappingSrflx,
934
935 #[error("invalid mDNS HostName, must end with .local and can only contain a single '.'")]
937 ErrInvalidMulticastDnshostName,
938
939 #[error("mdns is not supported")]
941 ErrMulticastDnsNotSupported,
942
943 #[error("ICE Agent can not be restarted when gathering")]
945 ErrRestartWhenGathering,
946
947 #[error("run was canceled by done")]
949 ErrRunCanceled,
950
951 #[error("TCPMux is not initialized")]
953 ErrTcpMuxNotInitialized,
954
955 #[error("conn with same remote addr already exists")]
957 ErrTcpRemoteAddrAlreadyExists,
958
959 #[error("failed to send packet")]
961 ErrSendPacket,
962 #[error("attribute not long enough to be ICE candidate")]
964 ErrAttributeTooShortIceCandidate,
965 #[error("could not parse component")]
967 ErrParseComponent,
968 #[error("could not parse priority")]
970 ErrParsePriority,
971 #[error("could not parse port")]
973 ErrParsePort,
974 #[error("could not parse related addresses")]
976 ErrParseRelatedAddr,
977 #[error("could not parse type")]
979 ErrParseType,
980 #[error("unknown candidate type")]
982 ErrUnknownCandidateType,
983 #[error("failed to get XOR-MAPPED-ADDRESS response")]
985 ErrGetXorMappedAddrResponse,
986 #[error("connection with same remote address already exists")]
988 ErrConnectionAddrAlreadyExist,
989 #[error("error reading streaming packet")]
991 ErrReadingStreamingPacket,
992 #[error("error writing to")]
994 ErrWriting,
995 #[error("error closing connection")]
997 ErrClosingConnection,
998 #[error("unable to determine networkType")]
1000 ErrDetermineNetworkType,
1001 #[error("missing protocol scheme")]
1003 ErrMissingProtocolScheme,
1004 #[error("too many colons in address")]
1006 ErrTooManyColonsAddr,
1007 #[error("unexpected error trying to read")]
1009 ErrRead,
1010 #[error("unknown role")]
1012 ErrUnknownRole,
1013 #[error("username mismatch")]
1015 ErrMismatchUsername,
1016 #[error("the ICE conn can't write STUN messages")]
1018 ErrIceWriteStunMessage,
1019 #[error("url parse: relative URL without a base")]
1021 ErrUrlParse,
1022 #[error("Candidate IP could not be found")]
1024 ErrCandidateIpNotFound,
1025
1026 #[error("conn is closed")]
1029 ErrConnClosed,
1030 #[error("read/write timeout")]
1032 ErrDeadlineExceeded,
1033 #[error("context is not supported for export_keying_material")]
1035 ErrContextUnsupported,
1036 #[error("packet is too short")]
1038 ErrDtlspacketInvalidLength,
1039 #[error("handshake is in progress")]
1041 ErrHandshakeInProgress,
1042 #[error("invalid content type")]
1044 ErrInvalidContentType,
1045 #[error("invalid mac")]
1047 ErrInvalidMac,
1048 #[error("packet length and declared length do not match")]
1050 ErrInvalidPacketLength,
1051 #[error("export_keying_material can not be used with a reserved label")]
1053 ErrReservedExportKeyingMaterial,
1054 #[error("client sent certificate verify but we have no certificate to verify")]
1056 ErrCertificateVerifyNoCertificate,
1057 #[error("client+server do not support any shared cipher suites")]
1059 ErrCipherSuiteNoIntersection,
1060 #[error("server hello can not be created without a cipher suite")]
1062 ErrCipherSuiteUnset,
1063 #[error("client sent certificate but did not verify it")]
1065 ErrClientCertificateNotVerified,
1066 #[error("server required client verification, but got none")]
1068 ErrClientCertificateRequired,
1069 #[error("server responded with SRTP Profile we do not support")]
1071 ErrClientNoMatchingSrtpProfile,
1072 #[error("client required Extended Master Secret extension, but server does not support it")]
1074 ErrClientRequiredButNoServerEms,
1075 #[error("server hello can not be created without a compression method")]
1077 ErrCompressionMethodUnset,
1078 #[error("client+server cookie does not match")]
1080 ErrCookieMismatch,
1081 #[error("cookie must not be longer then 255 bytes")]
1083 ErrCookieTooLong,
1084 #[error("PSK Identity Hint provided but PSK is nil")]
1086 ErrIdentityNoPsk,
1087 #[error("no certificate provided")]
1089 ErrInvalidCertificate,
1090 #[error("cipher spec invalid")]
1092 ErrInvalidCipherSpec,
1093 #[error("invalid or unknown cipher suite")]
1095 ErrInvalidCipherSuite,
1096 #[error("unable to determine if ClientKeyExchange is a public key or PSK Identity")]
1098 ErrInvalidClientKeyExchange,
1099 #[error("invalid or unknown compression method")]
1101 ErrInvalidCompressionMethod,
1102 #[error("ECDSA signature contained zero or negative values")]
1104 ErrInvalidEcdsasignature,
1105 #[error("invalid or unknown elliptic curve type")]
1107 ErrInvalidEllipticCurveType,
1108 #[error("invalid extension type")]
1110 ErrInvalidExtensionType,
1111 #[error("invalid hash algorithm")]
1113 ErrInvalidHashAlgorithm,
1114 #[error("invalid named curve")]
1116 ErrInvalidNamedCurve,
1117 #[error("invalid private key type")]
1119 ErrInvalidPrivateKey,
1120 #[error("named curve and private key type does not match")]
1122 ErrNamedCurveAndPrivateKeyMismatch,
1123 #[error("invalid server name format")]
1125 ErrInvalidSniFormat,
1126 #[error("invalid signature algorithm")]
1128 ErrInvalidSignatureAlgorithm,
1129 #[error("expected and actual key signature do not match")]
1131 ErrKeySignatureMismatch,
1132 #[error("Conn can not be created with a nil nextConn")]
1134 ErrNilNextConn,
1135 #[error("connection can not be created, no CipherSuites satisfy this Config")]
1137 ErrNoAvailableCipherSuites,
1138 #[error("connection can not be created, no SignatureScheme satisfy this Config")]
1140 ErrNoAvailableSignatureSchemes,
1141 #[error("no certificates configured")]
1143 ErrNoCertificates,
1144 #[error("no config provided")]
1146 ErrNoConfigProvided,
1147 #[error("client requested zero or more elliptic curves that are not supported by the server")]
1149 ErrNoSupportedEllipticCurves,
1150 #[error("unsupported protocol version")]
1152 ErrUnsupportedProtocolVersion,
1153 #[error("Certificate and PSK provided")]
1155 ErrPskAndCertificate,
1156 #[error("PSK and PSK Identity Hint must both be set for client")]
1158 ErrPskAndIdentityMustBeSetForClient,
1159 #[error("SRTP support was requested but server did not respond with use_srtp extension")]
1161 ErrRequestedButNoSrtpExtension,
1162 #[error("Certificate is mandatory for server")]
1164 ErrServerMustHaveCertificate,
1165 #[error("client requested SRTP but we have no matching profiles")]
1167 ErrServerNoMatchingSrtpProfile,
1168 #[error(
1170 "server requires the Extended Master Secret extension, but the client does not support it"
1171 )]
1172 ErrServerRequiredButNoClientEms,
1173 #[error("expected and actual verify data does not match")]
1175 ErrVerifyDataMismatch,
1176 #[error("handshake message unset, unable to marshal")]
1178 ErrHandshakeMessageUnset,
1179 #[error("invalid flight number")]
1181 ErrInvalidFlight,
1182 #[error("unable to generate key signature, unimplemented")]
1184 ErrKeySignatureGenerateUnimplemented,
1185 #[error("unable to verify key signature, unimplemented")]
1187 ErrKeySignatureVerifyUnimplemented,
1188 #[error("data length and declared length do not match")]
1190 ErrLengthMismatch,
1191 #[error("buffer not long enough to contain nonce")]
1193 ErrNotEnoughRoomForNonce,
1194 #[error("feature has not been implemented yet")]
1196 ErrNotImplemented,
1197 #[error("sequence number overflow")]
1199 ErrSequenceNumberOverflow,
1200 #[error("unable to marshal fragmented handshakes")]
1202 ErrUnableToMarshalFragmented,
1203 #[error("invalid state machine transition")]
1205 ErrInvalidFsmTransition,
1206 #[error("ApplicationData with epoch of 0")]
1208 ErrApplicationDataEpochZero,
1209 #[error("unhandled contentType")]
1211 ErrUnhandledContextType,
1212 #[error("context canceled")]
1214 ErrContextCanceled,
1215 #[error("empty fragment")]
1217 ErrEmptyFragment,
1218 #[error("Alert is Fatal or Close Notify")]
1220 ErrAlertFatalOrClose,
1221 #[error("renegotiation_info is not empty in an initial handshake")]
1223 ErrRenegotiationInfoNotEmpty,
1224 #[error("server sent an extension the client did not offer")]
1226 ErrUnsolicitedExtension,
1227 #[error("server selected a compression method the client did not offer")]
1229 ErrCompressionMethodNotOffered,
1230 #[error("client did not offer the null compression method")]
1232 ErrNoNullCompressionMethod,
1233 #[error("server's use_srtp extension is not a valid answer to the client's")]
1236 ErrInvalidUseSrtpAnswer,
1237 #[error("no keying material is exported without the extended master secret")]
1239 ErrExportWithoutExtendedMasterSecret,
1240 #[error("handshake did not complete in time")]
1242 ErrHandshakeTimeout,
1243 #[error("record payload exceeds 2^14 bytes")]
1245 ErrRecordOverflow,
1246 #[error("hello carries an extension type twice")]
1248 ErrDuplicateExtension,
1249 #[error(
1251 "Fragment buffer overflow. New size {new_size} is greater than specified max {max_size}"
1252 )]
1253 ErrFragmentBufferOverflow {
1254 new_size: usize,
1256 max_size: usize,
1258 },
1259 #[error("Client transport is not set yet")]
1261 ErrClientTransportNotSet,
1262
1263 #[error("endpoint stopping")]
1267 EndpointStopping,
1268 #[error("too many connections")]
1272 TooManyConnections,
1273 #[error("invalid DNS name: {0}")]
1275 InvalidDnsName(String),
1276 #[error("invalid remote address: {0}")]
1280 InvalidRemoteAddress(SocketAddr),
1281 #[error("no client config")]
1283 NoClientConfig,
1284 #[error("no server config")]
1286 NoServerConfig,
1287
1288 #[error("raw is too small for a SCTP chunk")]
1291 ErrChunkHeaderTooSmall,
1292 #[error("not enough data left in SCTP packet to satisfy requested length")]
1294 ErrChunkHeaderNotEnoughSpace,
1295 #[error("chunk PADDING is non-zero at offset")]
1297 ErrChunkHeaderPaddingNonZero,
1298 #[error("chunk has invalid length")]
1300 ErrChunkHeaderInvalidLength,
1301
1302 #[error("ChunkType is not of type ABORT")]
1304 ErrChunkTypeNotAbort,
1305 #[error("failed build Abort Chunk")]
1307 ErrBuildAbortChunkFailed,
1308 #[error("ChunkType is not of type COOKIEACK")]
1310 ErrChunkTypeNotCookieAck,
1311 #[error("ChunkType is not of type COOKIEECHO")]
1313 ErrChunkTypeNotCookieEcho,
1314 #[error("ChunkType is not of type ctError")]
1316 ErrChunkTypeNotCt,
1317 #[error("failed build Error Chunk")]
1319 ErrBuildErrorChunkFailed,
1320 #[error("failed to marshal stream")]
1322 ErrMarshalStreamFailed,
1323 #[error("chunk too short")]
1325 ErrChunkTooShort,
1326 #[error("ChunkType is not of type ForwardTsn")]
1328 ErrChunkTypeNotForwardTsn,
1329 #[error("ChunkType is not of type HEARTBEAT")]
1331 ErrChunkTypeNotHeartbeat,
1332 #[error("ChunkType is not of type HEARTBEATACK")]
1334 ErrChunkTypeNotHeartbeatAck,
1335 #[error("heartbeat is not long enough to contain Heartbeat Info")]
1337 ErrHeartbeatNotLongEnoughInfo,
1338 #[error("failed to parse param type")]
1340 ErrParseParamTypeFailed,
1341 #[error("heartbeat should only have HEARTBEAT param")]
1343 ErrHeartbeatParam,
1344 #[error("failed unmarshalling param in Heartbeat Chunk")]
1346 ErrHeartbeatChunkUnmarshal,
1347 #[error("unimplemented")]
1349 ErrUnimplemented,
1350 #[error("heartbeat Ack must have one param")]
1352 ErrHeartbeatAckParams,
1353 #[error("heartbeat Ack must have one param, and it should be a HeartbeatInfo")]
1355 ErrHeartbeatAckNotHeartbeatInfo,
1356 #[error("unable to marshal parameter for Heartbeat Ack")]
1358 ErrHeartbeatAckMarshalParam,
1359
1360 #[error("raw is too small for error cause")]
1362 ErrErrorCauseTooSmall,
1363
1364 #[error("unhandled ParamType: {typ}")]
1366 ErrParamTypeUnhandled {
1367 typ: u16,
1369 },
1370
1371 #[error("unexpected ParamType")]
1373 ErrParamTypeUnexpected,
1374
1375 #[error("param header too short")]
1377 ErrParamHeaderTooShort,
1378 #[error("param self reported length is shorter than header length")]
1380 ErrParamHeaderSelfReportedLengthShorter,
1381 #[error("param self reported length is longer than header length")]
1383 ErrParamHeaderSelfReportedLengthLonger,
1384 #[error("failed to parse param type")]
1386 ErrParamHeaderParseFailed,
1387
1388 #[error("packet to short")]
1390 ErrParamPacketTooShort,
1391 #[error("outgoing SSN reset request parameter too short")]
1393 ErrSsnResetRequestParamTooShort,
1394 #[error("failed unmarshalling SSN reset request parameter in RE-CONFIG chunk")]
1396 ErrUnmarshalSsnResetRequestParam,
1397 #[error("reconfig response parameter too short")]
1399 ErrReconfigRespParamTooShort,
1400 #[error("failed unmarshalling re-configuration response parameter in RE-CONFIG chunk")]
1402 ErrUnmarshalReconfigRespParam,
1403 #[error("invalid algorithm type")]
1405 ErrInvalidAlgorithmType,
1406
1407 #[error("failed to parse param type")]
1409 ErrInitChunkParseParamTypeFailed,
1410 #[error("failed unmarshalling param in Init Chunk")]
1412 ErrInitChunkUnmarshalParam,
1413 #[error("unable to marshal parameter for INIT/INITACK")]
1415 ErrInitAckMarshalParam,
1416
1417 #[error("ChunkType is not of type INIT")]
1419 ErrChunkTypeNotTypeInit,
1420 #[error("chunk Value isn't long enough for mandatory parameters exp")]
1422 ErrChunkValueNotLongEnough,
1423 #[error("ChunkType of type INIT flags must be all 0")]
1425 ErrChunkTypeInitFlagZero,
1426 #[error("failed to unmarshal INIT body")]
1428 ErrChunkTypeInitUnmarshalFailed,
1429 #[error("failed marshaling INIT common data")]
1431 ErrChunkTypeInitMarshalFailed,
1432 #[error("ChunkType of type INIT ACK InitiateTag must not be 0")]
1434 ErrChunkTypeInitInitiateTagZero,
1435 #[error("INIT ACK inbound stream request must be > 0")]
1437 ErrInitInboundStreamRequestZero,
1438 #[error("INIT ACK outbound stream request must be > 0")]
1440 ErrInitOutboundStreamRequestZero,
1441 #[error("INIT ACK Advertised Receiver Window Credit (a_rwnd) must be >= 1500")]
1443 ErrInitAdvertisedReceiver1500,
1444
1445 #[error("packet is smaller than the header size")]
1447 ErrChunkPayloadSmall,
1448 #[error("ChunkType is not of type PayloadData")]
1450 ErrChunkTypeNotPayloadData,
1451 #[error("failed unmarshalling payload data chunk")]
1453 ErrChunkUnmarshalPayloadData,
1454 #[error("ChunkType is not of type Reconfig")]
1456 ErrChunkTypeNotReconfig,
1457 #[error("ChunkReconfig has invalid ParamA")]
1459 ErrChunkReconfigInvalidParamA,
1460
1461 #[error("failed to parse param type")]
1463 ErrChunkParseParamTypeFailed,
1464 #[error("unable to marshal parameter A for reconfig")]
1466 ErrChunkMarshalParamAReconfigFailed,
1467 #[error("unable to marshal parameter B for reconfig")]
1469 ErrChunkMarshalParamBReconfigFailed,
1470
1471 #[error("ChunkType is not of type SACK")]
1473 ErrChunkTypeNotSack,
1474 #[error("SACK Chunk size is not large enough to contain header")]
1476 ErrSackSizeNotLargeEnoughInfo,
1477 #[error("failed unmarshalling SACK chunk")]
1479 ErrChunkUnmarshalSack,
1480
1481 #[error("invalid chunk size")]
1483 ErrInvalidChunkSize,
1484 #[error("ChunkType is not of type SHUTDOWN")]
1486 ErrChunkTypeNotShutdown,
1487 #[error("failed unmarshalling shutdown chunk")]
1489 ErrChunkUnmarshalShutdown,
1490
1491 #[error("ChunkType is not of type SHUTDOWN-ACK")]
1493 ErrChunkTypeNotShutdownAck,
1494 #[error("ChunkType is not of type SHUTDOWN-COMPLETE")]
1496 ErrChunkTypeNotShutdownComplete,
1497
1498 #[error("raw is smaller than the minimum length for a SCTP packet")]
1500 ErrPacketRawTooSmall,
1501 #[error("unable to parse SCTP chunk, not enough data for complete header")]
1503 ErrParseSctpChunkNotEnoughData,
1504 #[error("failed to unmarshal, contains unknown chunk type")]
1506 ErrUnmarshalUnknownChunkType,
1507 #[error("checksum mismatch theirs")]
1509 ErrChecksumMismatch,
1510
1511 #[error("unexpected chunk popped (unordered)")]
1513 ErrUnexpectedChuckPoppedUnordered,
1514 #[error("unexpected chunk popped (ordered)")]
1516 ErrUnexpectedChuckPoppedOrdered,
1517 #[error("unexpected q state (should've been selected)")]
1519 ErrUnexpectedQState,
1520 #[error("try again")]
1522 ErrTryAgain,
1523
1524 #[error("abort chunk, with following errors: {0}")]
1526 ErrAbortChunk(String),
1527 #[error("shutdown called in non-Established state")]
1529 ErrShutdownNonEstablished,
1530 #[error("association closed before connecting")]
1532 ErrAssociationClosedBeforeConn,
1533 #[error("association init failed")]
1535 ErrAssociationInitFailed,
1536 #[error("association handshake closed")]
1538 ErrAssociationHandshakeClosed,
1539 #[error("silently discard")]
1541 ErrSilentlyDiscard,
1542 #[error("the init not stored to send")]
1544 ErrInitNotStoredToSend,
1545 #[error("cookieEcho not stored to send")]
1547 ErrCookieEchoNotStoredToSend,
1548 #[error("sctp packet must not have a source port of 0")]
1550 ErrSctpPacketSourcePortZero,
1551 #[error("sctp packet must not have a destination port of 0")]
1553 ErrSctpPacketDestinationPortZero,
1554 #[error("init chunk must not be bundled with any other chunk")]
1556 ErrInitChunkBundled,
1557 #[error("init chunk expects a verification tag of 0 on the packet when out-of-the-blue")]
1559 ErrInitChunkVerifyTagNotZero,
1560 #[error("todo: handle Init when in state")]
1562 ErrHandleInitState,
1563 #[error("no cookie in InitAck")]
1565 ErrInitAckNoCookie,
1566 #[error("there already exists a stream with identifier")]
1568 ErrStreamAlreadyExist,
1569 #[error("Failed to create a stream with identifier")]
1571 ErrStreamCreateFailed,
1572 #[error("unable to be popped from inflight queue TSN")]
1574 ErrInflightQueueTsnPop,
1575 #[error("requested non-existent TSN")]
1577 ErrTsnRequestNotExist,
1578 #[error("sending reset packet in non-Established state")]
1580 ErrResetPacketInStateNotExist,
1581 #[error("unexpected parameter type")]
1583 ErrParameterType,
1584 #[error("sending payload data in non-Established state")]
1586 ErrPayloadDataStateNotExist,
1587 #[error("unhandled chunk type")]
1589 ErrChunkTypeUnhandled,
1590 #[error("handshake failed (INIT ACK)")]
1592 ErrHandshakeInitAck,
1593 #[error("handshake failed (COOKIE ECHO)")]
1595 ErrHandshakeCookieEcho,
1596
1597 #[error("outbound packet larger than maximum message size")]
1599 ErrOutboundPacketTooLarge,
1600 #[error(
1604 "a {size} byte message is over the {limit} byte limit of an SCTP association without \
1605 message interleaving (RFC 8831 section 6.6: the peer did not announce I-DATA); \
1606 SettingEngineBuilder::with_sctp_message_size_limit_without_interleaving(false) lifts it \
1607 up to the peer's max-message-size"
1608 )]
1609 ErrMessageTooLargeWithoutInterleaving {
1610 size: usize,
1612 limit: u32,
1614 },
1615 #[error("Stream closed")]
1617 ErrStreamClosed,
1618 #[error("Stream not existed")]
1620 ErrStreamNotExisted,
1621 #[error("Association not existed")]
1623 ErrAssociationNotExisted,
1624 #[error("Transport not existed")]
1626 ErrTransportNoExisted,
1627 #[error("Io EOF")]
1629 ErrEof,
1630 #[error("Invalid SystemTime")]
1632 ErrInvalidSystemTime,
1633 #[error("Net Conn read error")]
1635 ErrNetConnRead,
1636 #[error("Max Data Channel ID")]
1638 ErrMaxDataChannelID,
1639
1640 #[error(
1643 "DataChannel message is not long enough to determine type: (expected: {expected}, actual: {actual})"
1644 )]
1645 UnexpectedEndOfBuffer {
1646 expected: usize,
1648 actual: usize,
1650 },
1651 #[error("Unknown MessageType {0}")]
1653 InvalidMessageType(u8),
1654 #[error("Unknown ChannelType {0}")]
1656 InvalidChannelType(u8),
1657 #[error("Unknown PayloadProtocolIdentifier {0}")]
1659 InvalidPayloadProtocolIdentifier(u8),
1660 #[error("Unknow Protocol")]
1662 UnknownProtocol,
1663
1664 #[error("stream is nil")]
1667 ErrNilStream,
1668 #[error("incomplete frame header")]
1670 ErrIncompleteFrameHeader,
1671 #[error("incomplete frame data")]
1673 ErrIncompleteFrameData,
1674 #[error("incomplete file header")]
1676 ErrIncompleteFileHeader,
1677 #[error("IVF signature mismatch")]
1679 ErrSignatureMismatch,
1680 #[error("IVF version unknown, parser may not parse correctly")]
1682 ErrUnknownIVFVersion,
1683
1684 #[error("file not opened")]
1686 ErrFileNotOpened,
1687 #[error("invalid nil packet")]
1689 ErrInvalidNilPacket,
1690
1691 #[error("bad header signature")]
1693 ErrBadIDPageSignature,
1694 #[error("wrong header, expected beginning of stream")]
1696 ErrBadIDPageType,
1697 #[error("payload for id page must be 19 bytes")]
1699 ErrBadIDPageLength,
1700 #[error("bad payload signature")]
1702 ErrBadIDPagePayloadSignature,
1703 #[error("not enough data for payload header")]
1705 ErrShortPageHeader,
1706 #[error("bad OpusTags signature")]
1708 ErrBadOpusTagsSignature,
1709 #[error("unsupported channel mapping family")]
1711 ErrUnsupportedChannelMappingFamily,
1712
1713 #[error("data is not a H264 bitstream")]
1715 ErrDataIsNotH264Stream,
1716 #[error("data is not a H265 bitstream")]
1718 ErrDataIsNotH265Stream,
1719 #[error("Io EOF")]
1721 ErrIoEOF,
1722
1723 #[error("mDNS: port not support, only 5353 is supported")]
1726 ErrMDNSPortNotSupported,
1727 #[error("mDNS: connection is closed")]
1729 ErrMDNSConnectionClosed,
1730 #[error("mDNS: query not found")]
1732 ErrMDNSQueryNotFound,
1733 #[error("mDNS: parsing/packing of this type isn't available yet")]
1735 ErrNotStarted,
1736 #[error("mDNS: parsing/packing of this section has completed")]
1738 ErrSectionDone,
1739 #[error("mDNS: parsing/packing of this section is header")]
1741 ErrSectionHeader,
1742 #[error("mDNS: insufficient data for base length type")]
1744 ErrBaseLen,
1745 #[error("mDNS: insufficient data for calculated length type")]
1747 ErrCalcLen,
1748 #[error("mDNS: segment prefix is reserved")]
1750 ErrReserved,
1751 #[error("mDNS: too many pointers (>10)")]
1753 ErrTooManyPtr,
1754 #[error("mDNS: invalid pointer")]
1756 ErrInvalidPtr,
1757 #[error("mDNS: nil resource body")]
1759 ErrNilResourceBody,
1760 #[error("mDNS: insufficient data for resource body length")]
1762 ErrResourceLen,
1763 #[error("mDNS: segment length too long")]
1765 ErrSegTooLong,
1766 #[error("mDNS: zero length segment")]
1768 ErrZeroSegLen,
1769 #[error("mDNS: resource length too long")]
1771 ErrResTooLong,
1772 #[error("mDNS: too many Questions to pack (>65535)")]
1774 ErrTooManyQuestions,
1775 #[error("mDNS: too many Answers to pack (>65535)")]
1777 ErrTooManyAnswers,
1778 #[error("mDNS: too many Authorities to pack (>65535)")]
1780 ErrTooManyAuthorities,
1781 #[error("mDNS: too many Additionals to pack (>65535)")]
1783 ErrTooManyAdditionals,
1784 #[error("mDNS: name is not in canonical format (it must end with a .)")]
1786 ErrNonCanonicalName,
1787 #[error("mDNS: character string exceeds maximum length (255)")]
1789 ErrStringTooLong,
1790 #[error("mDNS: compressed name in SRV resource data")]
1792 ErrCompressedSrv,
1793 #[error("mDNS: empty builder msg")]
1795 ErrEmptyBuilderMsg,
1796
1797 #[error("connection closed")]
1801 ErrConnectionClosed,
1802
1803 #[error("data channel closed")]
1806 ErrDataChannelClosed,
1807
1808 #[error("data channel is not open yet")]
1812 ErrDataChannelNotOpen,
1813
1814 #[error("data channel stream identifier has not been assigned yet")]
1822 ErrDataChannelStreamIdNotAssigned,
1823
1824 #[error("data channel not existed")]
1827 ErrDataChannelNotExisted,
1828
1829 #[error("data channel send buffer full")]
1833 ErrSendBufferFull,
1834
1835 #[error("x509Cert expired")]
1837 ErrCertificateExpired,
1838
1839 #[error("an ICE server has no url")]
1842 ErrNoIceServerUrls,
1843
1844 #[error("turn server credentials required")]
1847 ErrNoTurnCredentials,
1848
1849 #[error("invalid turn server credentials")]
1852 ErrTurnCredentials,
1853
1854 #[error("track already exists")]
1856 ErrExistingTrack,
1857
1858 #[error("track not existed")]
1860 ErrTrackNotExisted,
1861
1862 #[error("private key type not supported")]
1865 ErrPrivateKeyType,
1866
1867 #[error("peerIdentity cannot be modified")]
1870 ErrModifyingPeerIdentity,
1871
1872 #[error("certificates cannot be modified")]
1875 ErrModifyingCertificates,
1876
1877 #[error("no certificate")]
1879 ErrNonCertificate,
1880
1881 #[error("bundle policy cannot be modified")]
1884 ErrModifyingBundlePolicy,
1885
1886 #[error("rtcp mux policy cannot be modified")]
1889 ErrModifyingRTCPMuxPolicy,
1890
1891 #[error("ice candidate pool size cannot be modified")]
1894 ErrModifyingICECandidatePoolSize,
1895
1896 #[error("data channel label exceeds size limit")]
1899 ErrStringSizeLimit,
1900
1901 #[error("negotiated set without channel id")]
1905 ErrNegotiatedWithoutID,
1906
1907 #[error("both max_packet_life_time and max_retransmits was set")]
1912 ErrRetransmitsOrPacketLifeTime,
1913
1914 #[error("codec not found")]
1916 ErrCodecNotFound,
1917
1918 #[error("remote description is not set")]
1921 ErrNoRemoteDescription,
1922
1923 #[error(
1926 "no media section of the remote description matches the candidate's sdpMid or sdpMLineIndex"
1927 )]
1928 ErrIceCandidateMediaSectionNotFound,
1929
1930 #[error("the candidate's usernameFragment is not its media section's ice-ufrag")]
1933 ErrIceCandidateUsernameFragmentMismatch,
1934
1935 #[error(
1939 "set_remote_description called with an ice-ufrag or ice-pwd that isn't RFC 8839 syntax"
1940 )]
1941 ErrSessionDescriptionInvalidIceCredentials,
1942
1943 #[error("offer SDP semantics does not match configuration")]
1946 ErrIncorrectSDPSemantics,
1947
1948 #[error("operation can not be run in current signaling state")]
1950 ErrIncorrectSignalingState,
1951
1952 #[error("protocol is larger then 65535 bytes")]
1955 ErrProtocolTooLarge,
1956
1957 #[error("label is larger than 65535 bytes")]
1960 ErrLabelTooLarge,
1961
1962 #[error("the {0} replay window of {1} packets is below the 64 RFC 3711 requires")]
1964 ErrSrtpReplayWindowTooSmall(&'static str, usize),
1965
1966 #[error("OperationError: {0}")]
1968 ErrOperationError(String),
1969
1970 #[error("{0:?} is not a DTMF tone")]
1972 ErrDtmfInvalidCharacter(char),
1973
1974 #[error("the data channel's send buffer is full")]
1977 ErrDataChannelBufferFull,
1978
1979 #[error("the data channel id is not below the SCTP transport's maxChannels")]
1982 ErrDataChannelIdAboveMaxChannels,
1983
1984 #[error("data channel id is already in use")]
1987 ErrDataChannelIdInUse,
1988
1989 #[error("RtpSender not created by this PeerConnection")]
1992 ErrSenderNotCreatedByConnection,
1993
1994 #[error("RtpSender's initial_track_id has already been set")]
1997 ErrSenderInitialTrackIdAlreadySet,
1998
1999 #[error("set_remote_description called with no fingerprint")]
2002 ErrSessionDescriptionNoFingerprint,
2003
2004 #[error("set_remote_description called with an invalid fingerprint")]
2007 ErrSessionDescriptionInvalidFingerprint,
2008
2009 #[error("set_remote_description called with multiple conflicting fingerprint")]
2012 ErrSessionDescriptionConflictingFingerprints,
2013
2014 #[error("set_remote_description called with an invalid setup attribute")]
2018 ErrSessionDescriptionInvalidSetup,
2019
2020 #[error("set_remote_description called with an invalid tls-id attribute")]
2024 ErrSessionDescriptionInvalidTlsId,
2025
2026 #[error("invalid identity assertion")]
2028 ErrInvalidIdentityAssertion,
2029
2030 #[error("set_remote_description called with no ice-ufrag")]
2033 ErrSessionDescriptionMissingIceUfrag,
2034
2035 #[error("set_remote_description called with no ice-pwd")]
2038 ErrSessionDescriptionMissingIcePwd,
2039
2040 #[error("set_remote_description called with multiple conflicting ice-ufrag values")]
2043 ErrSessionDescriptionConflictingIceUfrag,
2044
2045 #[error("set_remote_description called with multiple conflicting ice-pwd values")]
2048 ErrSessionDescriptionConflictingIcePwd,
2049
2050 #[error("set_remote_description called without a=cryptex while header encryption is required")]
2054 ErrSessionDescriptionMissingCryptex,
2055
2056 #[error("DTLS Handshake completed and no SRTP Protection Profile was chosen")]
2058 ErrNoSRTPProtectionProfile,
2059
2060 #[error("failed to generate certificate fingerprint")]
2062 ErrFailedToGenerateCertificateFingerprint,
2063
2064 #[error("operation failed no codecs are available")]
2066 ErrNoCodecsAvailable,
2067
2068 #[error("unable to start track, codec is not supported by remote")]
2070 ErrUnsupportedCodec,
2071
2072 #[error("Invalid state error")]
2074 InvalidStateError,
2075
2076 #[error("Invalid modification error")]
2078 InvalidModificationError,
2079
2080 #[error("Not found error")]
2083 NotFoundError,
2084
2085 #[error("Invalid access error")]
2089 InvalidAccessError,
2090
2091 #[error("Range error {0}")]
2093 RangeError(String),
2094
2095 #[error("Type error {0}")]
2097 TypeError(String),
2098
2099 #[error("Overconstrained: {0}")]
2103 OverconstrainedError(String),
2104
2105 #[error("SFrame was offered and the answer refused it: no media is sent")]
2108 ErrSFrameRefused,
2109
2110 #[error("SDP syntax error{}: {error}", .line_number.map(|n| format!(" on line {n}")).unwrap_or_default())]
2113 SdpSyntaxError {
2114 line_number: Option<usize>,
2116 error: Box<Error>,
2118 },
2119
2120 #[error("unable to populate media section, RTPSender created with no codecs")]
2123 ErrSenderWithNoCodecs,
2124
2125 #[error("unable to populate media section, RTPSender created with no ssrcs")]
2128 ErrSenderWithNoSSRCs,
2129
2130 #[error("new track must be of the same kind as previous")]
2132 ErrRTPSenderNewTrackHasIncorrectKind,
2133
2134 #[error("new track has incorrect envelope")]
2136 ErrRTPSenderNewTrackHasIncorrectEnvelope,
2137
2138 #[error("Sequence number transformer must be enabled before sending data")]
2140 ErrRTPSenderDataSent,
2141
2142 #[error("Sequence number transformer has been already enabled")]
2144 ErrRTPSenderSeqTransEnabled,
2145
2146 #[error("failed to unbind TrackLocal from PeerConnection")]
2148 ErrUnbindFailed,
2149
2150 #[error("the requested codec does not have a payloader")]
2152 ErrNoPayloaderForCodec,
2153
2154 #[error("a header extension must be registered with the same direction each time")]
2157 ErrRegisterHeaderExtensionInvalidDirection,
2158
2159 #[error("invalid direction")]
2161 ErrInvalidDirection,
2162
2163 #[error(
2167 "no header extension ID was free to use (the maximum of 254 extensions have been registered)"
2168 )]
2169 ErrRegisterHeaderExtensionNoFreeID,
2170
2171 #[error("simulcast probe limit has been reached, new SSRC has been discarded")]
2173 ErrSimulcastProbeOverflow,
2174
2175 #[error("enable detaching by calling webrtc.DetachDataChannels()")]
2177 ErrDetachNotEnabled,
2178 #[error("datachannel not opened yet, try calling Detach from OnOpen")]
2180 ErrDetachBeforeOpened,
2181 #[error("the DTLS transport has not started yet")]
2183 ErrDtlsTransportNotStarted,
2184 #[error("failed extracting keys from DTLS for SRTP")]
2186 ErrDtlsKeyExtractionFailed,
2187 #[error("failed to start SRTP")]
2189 ErrFailedToStartSRTP,
2190 #[error("failed to start SRTCP")]
2192 ErrFailedToStartSRTCP,
2193 #[error("attempted to start DTLSTransport that is not in new state")]
2195 ErrInvalidDTLSStart,
2196 #[error("peer didn't provide certificate via DTLS")]
2198 ErrNoRemoteCertificate,
2199 #[error("identity provider is not implemented")]
2201 ErrIdentityProviderNotImplemented,
2202 #[error("remote certificate does not match any fingerprint")]
2204 ErrNoMatchingCertificateFingerprint,
2205 #[error("unsupported fingerprint algorithm")]
2207 ErrUnsupportedFingerprintAlgorithm,
2208 #[error("ICE connection not started")]
2210 ErrICEConnectionNotStarted,
2211 #[error("unknown candidate type")]
2213 ErrICECandidateTypeUnknown,
2214 #[error("cannot convert ice.CandidateType into webrtc.ICECandidateType, invalid type")]
2216 ErrICEInvalidConvertCandidateType,
2217 #[error("ICEAgent does not exist")]
2219 ErrICEAgentNotExist,
2220 #[error("unable to convert ICE candidates to ICECandidates")]
2222 ErrICECandidatesConversionFailed,
2223 #[error("unknown ICE Role")]
2225 ErrICERoleUnknown,
2226 #[error("unknown protocol")]
2228 ErrICEProtocolUnknown,
2229 #[error("gatherer not started")]
2231 ErrICEGathererNotStarted,
2232 #[error("unknown network type")]
2234 ErrNetworkTypeUnknown,
2235 #[error("new sdp does not match previous offer")]
2237 ErrSDPDoesNotMatchOffer,
2238 #[error("new sdp does not match previous answer")]
2240 ErrSDPDoesNotMatchAnswer,
2241 #[error("the answer does not match the offer: {0}")]
2244 ErrAnswerDoesNotMatchOffer(String),
2245 #[error("provided value is not a valid enum value of type SDPType")]
2247 ErrPeerConnSDPTypeInvalidValue,
2248 #[error("invalid state change op")]
2250 ErrPeerConnStateChangeInvalid,
2251 #[error("unhandled state change op")]
2253 ErrPeerConnStateChangeUnhandled,
2254 #[error("invalid SDP type supplied to SetLocalDescription()")]
2256 ErrPeerConnSDPTypeInvalidValueSetLocalDescription,
2257 #[error("remoteDescription contained media section without mid value")]
2259 ErrPeerConnRemoteDescriptionWithoutMidValue,
2260 #[error("localDescription contained media section without mid value")]
2262 ErrPeerConnLocalDescriptionWithoutMidValue,
2263 #[error("remoteDescription has not been set yet")]
2265 ErrPeerConnRemoteDescriptionNil,
2266 #[error("localDescription has not been set yet")]
2268 ErrPeerConnLocalDescriptionNil,
2269 #[error("single media section has an explicit SSRC")]
2271 ErrPeerConnSingleMediaSectionHasExplicitSSRC,
2272 #[error("could not add transceiver for remote SSRC")]
2274 ErrPeerConnRemoteSSRCAddTransceiver,
2275 #[error("mid RTP Extensions required for Simulcast")]
2277 ErrPeerConnSimulcastMidRTPExtensionRequired,
2278 #[error("stream id RTP Extensions required for Simulcast")]
2280 ErrPeerConnSimulcastStreamIDRTPExtensionRequired,
2281 #[error("incoming SSRC failed Simulcast probing")]
2283 ErrPeerConnSimulcastIncomingSSRCFailed,
2284 #[error("failed collecting stats")]
2286 ErrPeerConnStatsCollectionFailed,
2287 #[error("add_transceiver_from_kind only accepts one RTPTransceiverInit")]
2289 ErrPeerConnAddTransceiverFromKindOnlyAcceptsOne,
2290 #[error("add_transceiver_from_track only accepts one RTPTransceiverInit")]
2292 ErrPeerConnAddTransceiverFromTrackOnlyAcceptsOne,
2293 #[error("add_transceiver_from_kind currently only supports recvonly")]
2295 ErrPeerConnAddTransceiverFromKindSupport,
2296 #[error("add_transceiver_from_track currently only supports sendonly and sendrecv")]
2298 ErrPeerConnAddTransceiverFromTrackSupport,
2299 #[error("TODO set_identity_provider")]
2301 ErrPeerConnSetIdentityProviderNotImplemented,
2302 #[error("write_rtcp failed to open write_stream")]
2304 ErrPeerConnWriteRTCPOpenWriteStream,
2305 #[error("cannot find transceiver with mid")]
2307 ErrPeerConnTransceiverMidNil,
2308 #[error("DTLSTransport must not be nil")]
2310 ErrRTPReceiverDTLSTransportNil,
2311 #[error("Receive has already been called")]
2313 ErrRTPReceiverReceiveAlreadyCalled,
2314 #[error("unable to find stream for Track with SSRC")]
2316 ErrRTPReceiverWithSSRCTrackStreamNotFound,
2317 #[error("no trackStreams found for SSRC")]
2319 ErrRTPReceiverForSSRCTrackStreamNotFound,
2320 #[error("no trackStreams found for RID")]
2322 ErrRTPReceiverForRIDTrackStreamNotFound,
2323 #[error("invalid RTP Receiver transition")]
2325 ErrRTPReceiverStateChangeInvalid,
2326 #[error("Track must not be nil")]
2328 ErrRTPSenderTrackNil,
2329 #[error("RTPSender not existed")]
2331 ErrRTPSenderNotExisted,
2332 #[error("Sender Track has been removed or replaced to nil")]
2334 ErrRTPSenderTrackRemoved,
2335 #[error("Sender cannot add encoding as rid is empty")]
2337 ErrRTPSenderRidNil,
2338 #[error("no a=imageattr line of the remote description can be satisfied")]
2342 ErrImageAttrUnsatisfiable,
2343 #[error("Sender cannot add encoding as there is no base track")]
2345 ErrRTPSenderNoBaseEncoding,
2346 #[error("Sender cannot add encoding as provided track does not match base track")]
2348 ErrRTPSenderBaseEncodingMismatch,
2349 #[error("Sender cannot encoding due to RID collision")]
2351 ErrRTPSenderRIDCollision,
2352 #[error("sender encodings name SSRC {0} for more than one stream")]
2356 ErrRTPSenderSsrcCollision(u32),
2357 #[error("RTCP feedback `{0} {1}` was not negotiated for the stream")]
2360 ErrRTCPFeedbackNotNegotiated(String, String),
2361 #[error("Sender cannot add encoding as its rid is not 1 to 255 alphanumeric characters")]
2364 ErrRTPSenderRidInvalid,
2365 #[error("Sender cannot use SSRC {0}: another local stream has it")]
2369 ErrRTPSenderSsrcTaken(u32),
2370 #[error("the remote description carries no identity assertion")]
2373 ErrNoRemoteIdentityAssertion,
2374 #[error("the verified identity does not cover every fingerprint of the remote description")]
2377 ErrIdentityFingerprintsNotCovered,
2378 #[error("the certificate in use is not among the fingerprints of the verified identity")]
2381 ErrIdentityCertificateNotCovered,
2382 #[error("Sender does not have track for RID")]
2384 ErrRTPSenderNoTrackForRID,
2385 #[error("RTPReceiver not existed")]
2387 ErrRTPReceiverNotExisted,
2388 #[error("DTLSTransport must not be nil")]
2390 ErrRTPSenderDTLSTransportNil,
2391 #[error("Send has already been called")]
2393 ErrRTPSenderSendAlreadyCalled,
2394 #[error("RTPTransceiver not existed")]
2396 ErrRTPTransceiverNotExisted,
2397 #[error("SCTPTransport not existed")]
2399 ErrSCTPTransportNotExisted,
2400 #[error("DTLSTransport not existed")]
2402 ErrDTLSTransportNotExisted,
2403 #[error("errRTPSenderTrackNil")]
2405 ErrRTPTransceiverCannotChangeMid,
2406 #[error("invalid state change in RTPTransceiver.setSending")]
2408 ErrRTPTransceiverSetSendingInvalidState,
2409 #[error("unsupported codec type by this transceiver")]
2411 ErrRTPTransceiverCodecUnsupported,
2412 #[error("DTLS not established")]
2414 ErrSCTPTransportDTLS,
2415 #[error("add_transceiver_sdp() called with 0 transceivers")]
2417 ErrSDPZeroTransceivers,
2418 #[error("invalid Media Section. Data channel section without a valid a=sctp-port")]
2420 ErrSDPSctpPortInvalid,
2421 #[error("invalid Media Section. Media + DataChannel both enabled")]
2423 ErrSDPMediaSectionMediaDataChanInvalid,
2424 #[error("invalid Media Section Track Index")]
2426 ErrSDPMediaSectionTrackInvalid,
2427 #[error("can't rollback from stable state")]
2429 ErrSignalingStateCannotRollback,
2430 #[error("invalid proposed signaling state transition: {0}")]
2432 ErrSignalingStateProposedTransitionInvalid(String),
2433 #[error("cannot convert to StatsICECandidatePairStateSucceeded invalid ice candidate state")]
2435 ErrStatsICECandidateStateInvalid,
2436 #[error("ICETransport can only be called in ICETransportStateNew")]
2438 ErrICETransportNotInNew,
2439 #[error(
2442 "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)"
2443 )]
2444 ErrICECandidateAddressOfPreviousDtlsAssociation(std::net::SocketAddr),
2445 #[error("bad Certificate PEM format")]
2447 ErrCertificatePEMFormatError,
2448 #[error("SCTP is not established")]
2450 ErrSCTPNotEstablished,
2451
2452 #[error("DataChannel is not opened")]
2454 ErrClosedPipe,
2455 #[error("Interceptor is not bind")]
2457 ErrInterceptorNotBind,
2458 #[error("excessive retries in CreateOffer")]
2460 ErrExcessiveRetries,
2461
2462 #[error("not long enough to be a RTP Packet")]
2464 ErrRTPTooShort,
2465
2466 #[error("RFC8851 mandates rid-syntax = %s\"a=rid:\" rid-id SP rid-dir")]
2468 SimulcastRidParseErrorSyntaxIdDirSplit,
2469 #[error("RFC8851 mandates rid-dir = %s\"send\" / %s\"recv\"")]
2471 SimulcastRidParseErrorUnknownDirection,
2472
2473 #[error("codec not found")]
2476 CodecNotFound,
2477 #[error("missing whitespace")]
2479 MissingWhitespace,
2480 #[error("missing colon")]
2482 MissingColon,
2483 #[error("payload type not found")]
2485 PayloadTypeNotFound,
2486 #[error("SdpInvalidSyntax: {0}")]
2488 SdpInvalidSyntax(String),
2489 #[error("SdpInvalidValue: {0}")]
2491 SdpInvalidValue(String),
2492 #[error("sdp: empty time_descriptions")]
2494 SdpEmptyTimeDescription,
2495 #[error("parse extmap: {0}")]
2497 ParseExtMap(String),
2498 #[error("{} --> {} <-- {}", .s.substring(0,*.p), .s.substring(*.p, *.p+1), .s.substring(*.p+1, .s.len())
2500 )]
2501 SyntaxError {
2502 s: String,
2504 p: usize,
2506 },
2507
2508 #[error("invalid PEM: {0}")]
2511 InvalidPEM(String),
2512 #[error("parse ip: {0}")]
2514 ParseIp(#[from] net::AddrParseError),
2515 #[error("parse int: {0}")]
2517 ParseInt(#[from] ParseIntError),
2518 #[error("{0}")]
2520 Io(#[source] IoError),
2521 #[error("url parse: {0}")]
2523 Url(#[from] url::ParseError),
2524 #[error("utf8: {0}")]
2526 Utf8(#[from] FromUtf8Error),
2527 #[error("{0}")]
2529 Std(#[source] StdError),
2530 #[error("Other RTCP Err: {0}")]
2533 OtherRtcpErr(String),
2534 #[error("Other RTP Err: {0}")]
2536 OtherRtpErr(String),
2537 #[error("Other SRTP Err: {0}")]
2539 OtherSrtpErr(String),
2540 #[error("Other STUN Err: {0}")]
2542 OtherStunErr(String),
2543 #[error("Other TURN Err: {0}")]
2545 OtherTurnErr(String),
2546 #[error("Other ICE Err: {0}")]
2548 OtherIceErr(String),
2549 #[error("Other DTLS Err: {0}")]
2551 OtherDtlsErr(String),
2552 #[error("Other SCTP Err: {0}")]
2554 OtherSctpErr(String),
2555 #[error("Other DataChannel Err: {0}")]
2557 OtherDataChannelErr(String),
2558 #[error("Other Interceptor Err: {0}")]
2560 OtherInterceptorErr(String),
2561 #[error("Other Media Err: {0}")]
2563 OtherMediaErr(String),
2564 #[error("Other mDNS Err: {0}")]
2566 OtherMdnsErr(String),
2567 #[error("Other SDP Err: {0}")]
2569 OtherSdpErr(String),
2570 #[error("Other PeerConnection Err: {0}")]
2572 OtherPeerConnectionErr(String),
2573 #[error("crypto: {0}")]
2575 Crypto(String),
2576 #[error("stream: unknown connection or listener")]
2579 ErrUnknownStream,
2580 #[error("stream: connection closed")]
2582 ErrStreamConnectionClosed,
2583 #[error("stream: message too long for its framing")]
2586 ErrStreamMessageTooLong,
2587 #[error("{0}")]
2588 Other(String),
2590}
2591
2592impl Error {
2593 pub fn from_std<T>(error: T) -> Self
2596 where
2597 T: std::error::Error + Send + Sync + 'static,
2598 {
2599 Error::Std(StdError(Box::new(error)))
2600 }
2601
2602 pub fn dom_exception_name(&self) -> Option<&'static str> {
2616 match self {
2617 Error::SdpSyntaxError { .. } | Error::SdpInvalidSyntax(_) => Some("OperationError"),
2618 Error::InvalidAccessError
2619 | Error::SdpInvalidValue(_)
2620 | Error::ErrPeerConnRemoteDescriptionWithoutMidValue
2621 | Error::ErrSessionDescriptionInvalidIceCredentials
2622 | Error::ErrSessionDescriptionNoFingerprint
2623 | Error::ErrSessionDescriptionInvalidFingerprint
2624 | Error::ErrSessionDescriptionConflictingFingerprints
2625 | Error::ErrSessionDescriptionInvalidSetup
2626 | Error::ErrSessionDescriptionInvalidTlsId
2627 | Error::ErrSessionDescriptionMissingIceUfrag
2628 | Error::ErrSessionDescriptionMissingIcePwd
2629 | Error::ErrSessionDescriptionConflictingIceUfrag
2630 | Error::ErrSessionDescriptionConflictingIcePwd
2631 | Error::ErrSessionDescriptionMissingCryptex => Some("InvalidAccessError"),
2632 Error::InvalidStateError
2633 | Error::ErrConnectionClosed
2634 | Error::ErrIncorrectSignalingState
2635 | Error::ErrSignalingStateCannotRollback
2636 | Error::ErrSignalingStateProposedTransitionInvalid(_) => Some("InvalidStateError"),
2637 Error::InvalidModificationError => Some("InvalidModificationError"),
2638 Error::NotFoundError => Some("NotFoundError"),
2639 Error::RangeError(_) => Some("RangeError"),
2640 Error::TypeError(_) => Some("TypeError"),
2641 Error::OverconstrainedError(_) => Some("OverconstrainedError"),
2642 _ => None,
2643 }
2644 }
2645
2646 pub fn rtc_error_detail(&self) -> Option<&'static str> {
2649 match self {
2650 Error::SdpSyntaxError { .. } | Error::SdpInvalidSyntax(_) => Some("sdp-syntax-error"),
2651 _ => None,
2652 }
2653 }
2654
2655 pub fn downcast_ref<T: std::error::Error + 'static>(&self) -> Option<&T> {
2660 if let Error::Std(s) = self {
2661 return s.0.downcast_ref();
2662 }
2663
2664 None
2665 }
2666}
2667
2668#[derive(Debug, Error)]
2674#[error("io error: {0}")]
2675pub struct IoError(#[from] pub io::Error);
2676
2677impl PartialEq for IoError {
2679 fn eq(&self, other: &Self) -> bool {
2680 self.0.kind() == other.0.kind()
2681 }
2682}
2683
2684impl From<io::Error> for Error {
2685 fn from(e: io::Error) -> Self {
2686 Error::Io(IoError(e))
2687 }
2688}
2689
2690#[derive(Debug, Error)]
2700#[error("{0}")]
2701pub struct StdError(pub Box<dyn std::error::Error + Send + Sync>);
2702
2703impl PartialEq for StdError {
2704 fn eq(&self, _: &Self) -> bool {
2705 false
2706 }
2707}
2708
2709impl<T> From<std::sync::PoisonError<T>> for Error {
2710 fn from(e: std::sync::PoisonError<T>) -> Self {
2711 Error::PoisonError(e.to_string())
2712 }
2713}
2714
2715impl From<SystemTimeError> for Error {
2716 fn from(e: SystemTimeError) -> Self {
2717 Error::Other(e.to_string())
2718 }
2719}
2720
2721pub fn flatten_errs(errs: Vec<impl Into<Error>>) -> Result<()> {
2725 if errs.is_empty() {
2726 Ok(())
2727 } else {
2728 let errs_strs: Vec<String> = errs.into_iter().map(|e| e.into().to_string()).collect();
2729 Err(Error::Other(errs_strs.join("\n")))
2730 }
2731}