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("an RTCP CNAME must be 1 to 255 octets long")]
246 ErrRtcpCnameLength,
247 #[error("Reason must be < 255 octets long")]
249 ReasonTooLong,
250 #[error("Invalid packet version")]
252 BadVersion,
253 #[error("Invalid padding value")]
255 WrongPadding,
256 #[error("Wrong feedback message type")]
258 WrongFeedbackType,
259 #[error("Wrong payload type")]
261 WrongPayloadType,
262 #[error("Header length is too small")]
264 HeaderTooSmall,
265 #[error("Media SSRC must be 0")]
267 SsrcMustBeZero,
268 #[error("Missing REMB identifier")]
270 MissingRembIdentifier,
271 #[error("SSRC num and length do not match")]
273 SsrcNumAndLengthMismatch,
274 #[error("Invalid size or startIndex")]
276 InvalidSizeOrStartIndex,
277 #[error("Delta exceed limit")]
279 DeltaExceedLimit,
280 #[error("Packet status chunk must be 2 bytes")]
282 PacketStatusChunkLength,
283 #[error("Invalid bitrate")]
285 InvalidBitrate,
286 #[error("Wrong chunk type")]
288 WrongChunkType,
289 #[error("Struct contains unexpected member type")]
291 BadStructMemberType,
292 #[error("Cannot read into non-pointer")]
294 BadReadParameter,
295 #[error("Invalid block size")]
297 InvalidBlockSize,
298
299 #[error("RTP header size insufficient")]
302 ErrHeaderSizeInsufficient,
303 #[error("RTP header size insufficient for extension")]
305 ErrHeaderSizeInsufficientForExtension,
306 #[error("buffer too small")]
308 ErrBufferTooSmall,
309 #[error("extension not enabled")]
311 ErrHeaderExtensionsNotEnabled,
312 #[error("extension not found")]
314 ErrHeaderExtensionNotFound,
315
316 #[error("header extension id must be between 1 and 14 for RFC 5285 extensions")]
318 ErrRfc8285oneByteHeaderIdrange,
319 #[error("header extension payload must be 16bytes or less for RFC 5285 one byte extensions")]
321 ErrRfc8285oneByteHeaderSize,
322
323 #[error("header extension id must be between 1 and 255 for RFC 5285 extensions")]
325 ErrRfc8285twoByteHeaderIdrange,
326 #[error("header extension payload must be 255bytes or less for RFC 5285 two byte extensions")]
328 ErrRfc8285twoByteHeaderSize,
329
330 #[error("header extension id must be 0 for none RFC 5285 extensions")]
332 ErrRfc3550headerIdrange,
333
334 #[error("packet is not large enough")]
336 ErrShortPacket,
337 #[error("invalid nil packet")]
339 ErrNilPacket,
340 #[error("too many PDiff")]
342 ErrTooManyPDiff,
343 #[error("too many spatial layers")]
345 ErrTooManySpatialLayers,
346 #[error("NALU Type is unhandled")]
348 ErrUnhandledNaluType,
349
350 #[error("corrupted h265 packet")]
352 ErrH265CorruptedPacket,
353 #[error("invalid h265 packet type")]
355 ErrInvalidH265PacketType,
356
357 #[error("payload is too small for OBU extension header")]
359 ErrPayloadTooSmallForObuExtensionHeader,
360 #[error("payload is too small for OBU payload size")]
362 ErrPayloadTooSmallForObuPayloadSize,
363
364 #[error("extension_payload must be in 32-bit words")]
366 HeaderExtensionPayloadNot32BitWords,
367 #[error("too many CSRCs: {0} exceeds the 4-bit CC field maximum of 15")]
369 TooManyCSRCs(usize),
370 #[error(
372 "one-byte header extension payload length {0} is outside the RFC 8285 valid range of 1-16 bytes"
373 )]
374 OneByteHeaderExtensionPayloadOutOfRange(usize),
375 #[error(
377 "two-byte header extension payload length {0} exceeds the RFC 8285 maximum of 255 bytes"
378 )]
379 TwoByteHeaderExtensionPayloadTooLarge(usize),
380 #[error("total extension payload length {0} exceeds u16::MAX (65535 bytes)")]
382 ExtensionPayloadTotalOverflow(usize),
383 #[error("NALU length {0} exceeds u16::MAX (65535 bytes)")]
385 NaluTooLarge(usize),
386 #[error("audio level overflow")]
388 AudioLevelOverflow,
389 #[error("playout delay overflow")]
391 PlayoutDelayOverflow,
392 #[error("payload is not large enough")]
394 PayloadIsNotLargeEnough,
395 #[error("STAP-A declared size({0}) is larger than buffer({1})")]
397 StapASizeLargerThanBuffer(usize, usize),
398 #[error("nalu type {0} is currently not handled")]
400 NaluTypeIsNotHandled(u8),
401
402 #[error("duplicated packet")]
405 ErrDuplicated,
406 #[error("SRTP master key is not long enough")]
408 ErrShortSrtpMasterKey,
409 #[error("SRTP master salt is not long enough")]
411 ErrShortSrtpMasterSalt,
412 #[error("no such SRTP Profile")]
414 ErrNoSuchSrtpProfile,
415 #[error("indexOverKdr > 0 is not supported yet")]
417 ErrNonZeroKdrNotSupported,
418 #[error("exporter called with wrong label")]
420 ErrExporterWrongLabel,
421 #[error("no config provided")]
423 ErrNoConfig,
424 #[error("no conn provided")]
426 ErrNoConn,
427 #[error("failed to verify auth tag")]
429 ErrFailedToVerifyAuthTag,
430 #[error("packet is too short to be RTP packet")]
432 ErrTooShortRtp,
433 #[error("packet is too short to be RTCP packet")]
435 ErrTooShortRtcp,
436 #[error("payload differs")]
438 ErrPayloadDiffers,
439 #[error("started channel used incorrectly, should only be closed")]
441 ErrStartedChannelUsedIncorrectly,
442 #[error("stream has not been inited, unable to close")]
444 ErrStreamNotInited,
445 #[error("stream is already closed")]
447 ErrStreamAlreadyClosed,
448 #[error("stream is already inited")]
450 ErrStreamAlreadyInited,
451 #[error("failed to cast child")]
453 ErrFailedTypeAssertion,
454 #[error("exceeded the maximum number of packets")]
456 ErrExceededMaxPackets,
457
458 #[error("index_over_kdr > 0 is not supported yet")]
460 UnsupportedIndexOverKdr,
461 #[error("invalid master key length for aes_256_cm")]
463 InvalidMasterKeyLength,
464 #[error("invalid master salt length for aes_256_cm")]
466 InvalidMasterSaltLength,
467 #[error("out_len > 32 is not supported for aes_256_cm")]
469 UnsupportedOutLength,
470 #[error("SRTP Master Key must be len {0}, got {1}")]
472 SrtpMasterKeyLength(usize, usize),
473 #[error("SRTP Salt must be len {0}, got {1}")]
475 SrtpSaltLength(usize, usize),
476 #[error("SyntaxError: {0}")]
478 ExtMapParse(String),
479 #[error("ssrc {0} not exist in srtp_ssrc_state")]
481 SsrcMissingFromSrtp(u32),
482 #[error("srtp ssrc={0} index={1}: duplicated")]
484 SrtpSsrcDuplicated(u32, u16),
485 #[error("srtp ssrc={0} seq={1}: packet index already used for encryption")]
487 SrtpIndexReused(u32, u16),
488 #[error("srtp ssrc={0}: refused, the context already tracks {1} SSRCs")]
490 SrtpTooManySsrcs(u32, usize),
491 #[error("srtcp ssrc={0} index={1}: duplicated")]
493 SrtcpSsrcDuplicated(u32, usize),
494 #[error("ssrc {0} not exist in srtcp_ssrc_state")]
496 SsrcMissingFromSrtcp(u32),
497 #[error("Stream with ssrc {0} exists")]
499 StreamWithSsrcExists(u32),
500 #[error("Session RTP/RTCP type must be same as input buffer")]
502 SessionRtpRtcpTypeMismatch,
503 #[error("Session EOF")]
505 SessionEof,
506 #[error("too short SRTP packet: only {0} bytes, expected > {1} bytes")]
508 SrtpTooSmall(usize, usize),
509 #[error("too short SRTCP packet: only {0} bytes, expected > {1} bytes")]
511 SrtcpTooSmall(usize, usize),
512 #[error("failed to verify rtp auth tag")]
514 RtpFailedToVerifyAuthTag,
515 #[error("too short auth tag: only {0} bytes, expected > {1} bytes")]
517 RtcpInvalidLengthAuthTag(usize, usize),
518 #[error("failed to verify rtcp auth tag")]
520 RtcpFailedToVerifyAuthTag,
521 #[error("SessionSRTP has been closed")]
523 SessionSrtpAlreadyClosed,
524 #[error("this stream is not a RTPStream")]
526 InvalidRtpStream,
527 #[error("this stream is not a RTCPStream")]
529 InvalidRtcpStream,
530
531 #[error("attribute not found")]
534 ErrAttributeNotFound,
535 #[error("transaction is stopped")]
537 ErrTransactionStopped,
538 #[error("transaction not exists")]
540 ErrTransactionNotExists,
541 #[error("transaction exists with same id")]
543 ErrTransactionExists,
544 #[error("agent is closed")]
546 ErrAgentClosed,
547 #[error("transaction is timed out")]
549 ErrTransactionTimeOut,
550 #[error("no default reason for ErrorCode")]
552 ErrNoDefaultReason,
553 #[error("unexpected EOF")]
555 ErrUnexpectedEof,
556 #[error("attribute size is invalid")]
558 ErrAttributeSizeInvalid,
559 #[error("attribute size overflow")]
561 ErrAttributeSizeOverflow,
562 #[error("attempt to decode to nil message")]
564 ErrDecodeToNil,
565 #[error("unexpected EOF: not enough bytes to read header")]
567 ErrUnexpectedHeaderEof,
568 #[error("integrity check failed")]
570 ErrIntegrityMismatch,
571 #[error("fingerprint check failed")]
573 ErrFingerprintMismatch,
574 #[error("FINGERPRINT before MESSAGE-INTEGRITY attribute")]
576 ErrFingerprintBeforeIntegrity,
577 #[error("bad UNKNOWN-ATTRIBUTES size")]
579 ErrBadUnknownAttrsSize,
580 #[error("invalid length of IP value")]
582 ErrBadIpLength,
583 #[error("no connection provided")]
585 ErrNoConnection,
586 #[error("client is closed")]
588 ErrClientClosed,
589 #[error("no agent is set")]
591 ErrNoAgent,
592 #[error("collector is closed")]
594 ErrCollectorClosed,
595 #[error("unsupported network")]
597 ErrUnsupportedNetwork,
598 #[error("invalid url")]
600 ErrInvalidUrl,
601 #[error("unknown scheme type")]
603 ErrSchemeType,
604 #[error("invalid hostname")]
606 ErrHost,
607
608 #[error("turn: RelayAddress must be valid IP to use RelayAddressGeneratorStatic")]
611 ErrRelayAddressInvalid,
612 #[error("turn: PacketConnConfigs and ConnConfigs are empty, unable to proceed")]
614 ErrNoAvailableConns,
615 #[error("turn: PacketConnConfig must have a non-nil Conn")]
617 ErrConnUnset,
618 #[error("turn: ListenerConfig must have a non-nil Listener")]
620 ErrListenerUnset,
621 #[error("turn: RelayAddressGenerator has invalid ListeningAddress")]
623 ErrListeningAddressInvalid,
624 #[error("turn: RelayAddressGenerator in RelayConfig is unset")]
626 ErrRelayAddressGeneratorUnset,
627 #[error("turn: max retries exceeded")]
629 ErrMaxRetriesExceeded,
630 #[error("turn: MaxPort must be not 0")]
632 ErrMaxPortNotZero,
633 #[error("turn: MaxPort must be not 0")]
635 ErrMinPortNotZero,
636 #[error("turn: MaxPort less than MinPort")]
638 ErrMaxPortLessThanMinPort,
639 #[error("turn: relay_conn cannot not be nil")]
641 ErrNilConn,
642 #[error("turn: TODO")]
644 ErrTodo,
645 #[error("turn: already listening")]
647 ErrAlreadyListening,
648 #[error("turn: Server failed to close")]
650 ErrFailedToClose,
651 #[error("turn: failed to retransmit transaction")]
653 ErrFailedToRetransmitTransaction,
654 #[error("all retransmissions failed")]
656 ErrAllRetransmissionsFailed,
657 #[error("no binding found for channel")]
659 ErrChannelBindNotFound,
660 #[error("STUN server address is not set for the client")]
662 ErrStunserverAddressNotSet,
663 #[error("only one Allocate() caller is allowed")]
665 ErrOneAllocateOnly,
666 #[error("already allocated")]
668 ErrAlreadyAllocated,
669 #[error("non-STUN message from STUN server")]
671 ErrNonStunmessage,
672 #[error("failed to decode STUN message")]
674 ErrFailedToDecodeStun,
675 #[error("unexpected STUN request message")]
677 ErrUnexpectedStunrequestMessage,
678 #[error("channel number not in [0x4000, 0x7FFF]")]
680 ErrInvalidChannelNumber,
681 #[error("channelData length != len(Data)")]
683 ErrBadChannelDataLength,
684 #[error("invalid value for requested family attribute")]
686 ErrInvalidRequestedFamilyValue,
687 #[error("fake error")]
689 ErrFakeErr,
690 #[error("use of closed network connection")]
692 ErrClosed,
693 #[error("addr is not a net.UDPAddr")]
695 ErrUdpaddrCast,
696 #[error("try-lock is already locked")]
698 ErrDoubleLock,
699 #[error("transaction closed")]
701 ErrTransactionClosed,
702 #[error("wait_for_result called on non-result transaction")]
704 ErrWaitForResultOnNonResultTransaction,
705 #[error("failed to build refresh request")]
707 ErrFailedToBuildRefreshRequest,
708 #[error("failed to refresh allocation")]
710 ErrFailedToRefreshAllocation,
711 #[error("failed to get lifetime from refresh response")]
713 ErrFailedToGetLifetime,
714 #[error("too short buffer")]
716 ErrShortBuffer,
717 #[error("unexpected response type")]
719 ErrUnexpectedResponse,
720 #[error("AllocatePacketConn must be set")]
722 ErrAllocatePacketConnMustBeSet,
723 #[error("AllocateConn must be set")]
725 ErrAllocateConnMustBeSet,
726 #[error("LeveledLogger must be set")]
728 ErrLeveledLoggerMustBeSet,
729 #[error("you cannot use the same channel number with different peer")]
731 ErrSameChannelDifferentPeer,
732 #[error("allocations must not be created with nil FivTuple")]
734 ErrNilFiveTuple,
735 #[error("allocations must not be created with nil FiveTuple.src_addr")]
737 ErrNilFiveTupleSrcAddr,
738 #[error("allocations must not be created with nil FiveTuple.dst_addr")]
740 ErrNilFiveTupleDstAddr,
741 #[error("allocations must not be created with nil turnSocket")]
743 ErrNilTurnSocket,
744 #[error("allocations must not be created with a lifetime of 0")]
746 ErrLifetimeZero,
747 #[error("allocation attempt created with duplicate FiveTuple")]
749 ErrDupeFiveTuple,
750 #[error("failed to cast net.Addr to *net.UDPAddr")]
752 ErrFailedToCastUdpaddr,
753 #[error("failed to generate nonce")]
755 ErrFailedToGenerateNonce,
756 #[error("failed to send error message")]
758 ErrFailedToSendError,
759 #[error("duplicated Nonce generated, discarding request")]
761 ErrDuplicatedNonce,
762 #[error("no such user exists")]
764 ErrNoSuchUser,
765 #[error("unexpected class")]
767 ErrUnexpectedClass,
768 #[error("unexpected method")]
770 ErrUnexpectedMethod,
771 #[error("failed to handle")]
773 ErrFailedToHandle,
774 #[error("unhandled STUN packet")]
776 ErrUnhandledStunpacket,
777 #[error("unable to handle ChannelData")]
779 ErrUnableToHandleChannelData,
780 #[error("failed to create stun message from packet")]
782 ErrFailedToCreateStunpacket,
783 #[error("failed to create channel data from packet")]
785 ErrFailedToCreateChannelData,
786 #[error("relay already allocated for 5-TUPLE")]
788 ErrRelayAlreadyAllocatedForFiveTuple,
789 #[error("RequestedTransport must be UDP")]
791 ErrRequestedTransportMustBeUdp,
792 #[error("no support for DONT-FRAGMENT")]
794 ErrNoDontFragmentSupport,
795 #[error("Request must not contain RESERVATION-TOKEN and EVEN-PORT")]
797 ErrRequestWithReservationTokenAndEvenPort,
798 #[error("no allocation found")]
800 ErrNoAllocationFound,
801 #[error("unable to handle send-indication, no permission added")]
803 ErrNoPermission,
804 #[error("packet write smaller than packet")]
806 ErrShortWrite,
807 #[error("no such channel bind")]
809 ErrNoSuchChannelBind,
810 #[error("failed writing to socket")]
812 ErrFailedWriteSocket,
813
814 #[error("Unknown type")]
817 ErrUnknownType,
818
819 #[error("queries not supported in stun address")]
821 ErrStunQuery,
822
823 #[error("invalid query")]
825 ErrInvalidQuery,
826
827 #[error("url parse: invalid port number")]
829 ErrPort,
830
831 #[error("local username fragment is less than 24 bits long")]
834 ErrLocalUfragInsufficientBits,
835
836 #[error("local password is less than 128 bits long")]
839 ErrLocalPwdInsufficientBits,
840
841 #[error("local username fragment is longer than 32 characters or not made of ice-chars")]
844 ErrLocalUfragInvalid,
845
846 #[error("local password is longer than 256 characters or not made of ice-chars")]
849 ErrLocalPwdInvalid,
850
851 #[error("a local srflx, prflx or relay candidate has no related address")]
854 ErrLocalCandidateWithoutRelatedAddress,
855
856 #[error("invalid transport protocol type")]
858 ErrProtoType,
859
860 #[error("no candidate pairs available")]
862 ErrNoCandidatePairs,
863
864 #[error("connecting canceled by caller")]
866 ErrCanceledByCaller,
867
868 #[error("attempted to start agent twice")]
870 ErrMultipleStart,
871
872 #[error("remote ufrag is empty")]
874 ErrRemoteUfragEmpty,
875
876 #[error("remote pwd is empty")]
878 ErrRemotePwdEmpty,
879
880 #[error("no on_candidate provided")]
882 ErrNoOnCandidateHandler,
883
884 #[error("attempting to gather candidates during gathering state")]
886 ErrMultipleGatherAttempted,
887
888 #[error("username is empty")]
890 ErrUsernameEmpty,
891
892 #[error("password is empty")]
894 ErrPasswordEmpty,
895
896 #[error("failed to parse address")]
898 ErrAddressParseFailed,
899
900 #[error("lite agents must only use host candidates")]
902 ErrLiteUsingNonHostCandidates,
903
904 #[error("lite support only")]
906 ErrLiteSupportOnly,
907
908 #[error("agent does not need URL with selected candidate types")]
910 ErrUselessUrlsProvided,
911
912 #[error("unsupported 1:1 NAT IP candidate type")]
914 ErrUnsupportedNat1to1IpCandidateType,
915
916 #[error("invalid 1:1 NAT IP mapping")]
918 ErrInvalidNat1to1IpMapping,
919
920 #[error("external mapped IP not found")]
922 ErrExternalMappedIpNotFound,
923
924 #[error("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate")]
927 ErrMulticastDnsWithNat1to1IpMapping,
928
929 #[error("1:1 NAT IP mapping for host candidate ineffective")]
932 ErrIneffectiveNat1to1IpMappingHost,
933
934 #[error("1:1 NAT IP mapping for srflx candidate ineffective")]
937 ErrIneffectiveNat1to1IpMappingSrflx,
938
939 #[error("invalid mDNS HostName, must end with .local and can only contain a single '.'")]
941 ErrInvalidMulticastDnshostName,
942
943 #[error("mdns is not supported")]
945 ErrMulticastDnsNotSupported,
946
947 #[error("ICE Agent can not be restarted when gathering")]
949 ErrRestartWhenGathering,
950
951 #[error("run was canceled by done")]
953 ErrRunCanceled,
954
955 #[error("TCPMux is not initialized")]
957 ErrTcpMuxNotInitialized,
958
959 #[error("conn with same remote addr already exists")]
961 ErrTcpRemoteAddrAlreadyExists,
962
963 #[error("failed to send packet")]
965 ErrSendPacket,
966 #[error("attribute not long enough to be ICE candidate")]
968 ErrAttributeTooShortIceCandidate,
969 #[error("could not parse component")]
971 ErrParseComponent,
972 #[error("could not parse priority")]
974 ErrParsePriority,
975 #[error("could not parse port")]
977 ErrParsePort,
978 #[error("could not parse related addresses")]
980 ErrParseRelatedAddr,
981 #[error("could not parse type")]
983 ErrParseType,
984 #[error("unknown candidate type")]
986 ErrUnknownCandidateType,
987 #[error("failed to get XOR-MAPPED-ADDRESS response")]
989 ErrGetXorMappedAddrResponse,
990 #[error("connection with same remote address already exists")]
992 ErrConnectionAddrAlreadyExist,
993 #[error("error reading streaming packet")]
995 ErrReadingStreamingPacket,
996 #[error("error writing to")]
998 ErrWriting,
999 #[error("error closing connection")]
1001 ErrClosingConnection,
1002 #[error("unable to determine networkType")]
1004 ErrDetermineNetworkType,
1005 #[error("missing protocol scheme")]
1007 ErrMissingProtocolScheme,
1008 #[error("too many colons in address")]
1010 ErrTooManyColonsAddr,
1011 #[error("unexpected error trying to read")]
1013 ErrRead,
1014 #[error("unknown role")]
1016 ErrUnknownRole,
1017 #[error("username mismatch")]
1019 ErrMismatchUsername,
1020 #[error("the ICE conn can't write STUN messages")]
1022 ErrIceWriteStunMessage,
1023 #[error("url parse: relative URL without a base")]
1025 ErrUrlParse,
1026 #[error("Candidate IP could not be found")]
1028 ErrCandidateIpNotFound,
1029
1030 #[error("conn is closed")]
1033 ErrConnClosed,
1034 #[error("read/write timeout")]
1036 ErrDeadlineExceeded,
1037 #[error("context is not supported for export_keying_material")]
1039 ErrContextUnsupported,
1040 #[error("packet is too short")]
1042 ErrDtlspacketInvalidLength,
1043 #[error("handshake is in progress")]
1045 ErrHandshakeInProgress,
1046 #[error("invalid content type")]
1048 ErrInvalidContentType,
1049 #[error("invalid mac")]
1051 ErrInvalidMac,
1052 #[error("packet length and declared length do not match")]
1054 ErrInvalidPacketLength,
1055 #[error("export_keying_material can not be used with a reserved label")]
1057 ErrReservedExportKeyingMaterial,
1058 #[error("client sent certificate verify but we have no certificate to verify")]
1060 ErrCertificateVerifyNoCertificate,
1061 #[error("client+server do not support any shared cipher suites")]
1063 ErrCipherSuiteNoIntersection,
1064 #[error("server hello can not be created without a cipher suite")]
1066 ErrCipherSuiteUnset,
1067 #[error("client sent certificate but did not verify it")]
1069 ErrClientCertificateNotVerified,
1070 #[error("server required client verification, but got none")]
1072 ErrClientCertificateRequired,
1073 #[error("server responded with SRTP Profile we do not support")]
1075 ErrClientNoMatchingSrtpProfile,
1076 #[error("client required Extended Master Secret extension, but server does not support it")]
1078 ErrClientRequiredButNoServerEms,
1079 #[error("server hello can not be created without a compression method")]
1081 ErrCompressionMethodUnset,
1082 #[error("client+server cookie does not match")]
1084 ErrCookieMismatch,
1085 #[error("cookie must not be longer then 255 bytes")]
1087 ErrCookieTooLong,
1088 #[error("PSK Identity Hint provided but PSK is nil")]
1090 ErrIdentityNoPsk,
1091 #[error("no certificate provided")]
1093 ErrInvalidCertificate,
1094 #[error("cipher spec invalid")]
1096 ErrInvalidCipherSpec,
1097 #[error("invalid or unknown cipher suite")]
1099 ErrInvalidCipherSuite,
1100 #[error("unable to determine if ClientKeyExchange is a public key or PSK Identity")]
1102 ErrInvalidClientKeyExchange,
1103 #[error("invalid or unknown compression method")]
1105 ErrInvalidCompressionMethod,
1106 #[error("ECDSA signature contained zero or negative values")]
1108 ErrInvalidEcdsasignature,
1109 #[error("invalid or unknown elliptic curve type")]
1111 ErrInvalidEllipticCurveType,
1112 #[error("invalid extension type")]
1114 ErrInvalidExtensionType,
1115 #[error("invalid hash algorithm")]
1117 ErrInvalidHashAlgorithm,
1118 #[error("invalid named curve")]
1120 ErrInvalidNamedCurve,
1121 #[error("invalid private key type")]
1123 ErrInvalidPrivateKey,
1124 #[error("named curve and private key type does not match")]
1126 ErrNamedCurveAndPrivateKeyMismatch,
1127 #[error("invalid server name format")]
1129 ErrInvalidSniFormat,
1130 #[error("invalid signature algorithm")]
1132 ErrInvalidSignatureAlgorithm,
1133 #[error("expected and actual key signature do not match")]
1135 ErrKeySignatureMismatch,
1136 #[error("Conn can not be created with a nil nextConn")]
1138 ErrNilNextConn,
1139 #[error("connection can not be created, no CipherSuites satisfy this Config")]
1141 ErrNoAvailableCipherSuites,
1142 #[error("connection can not be created, no SignatureScheme satisfy this Config")]
1144 ErrNoAvailableSignatureSchemes,
1145 #[error("no certificates configured")]
1147 ErrNoCertificates,
1148 #[error("no config provided")]
1150 ErrNoConfigProvided,
1151 #[error("client requested zero or more elliptic curves that are not supported by the server")]
1153 ErrNoSupportedEllipticCurves,
1154 #[error("unsupported protocol version")]
1156 ErrUnsupportedProtocolVersion,
1157 #[error("Certificate and PSK provided")]
1159 ErrPskAndCertificate,
1160 #[error("PSK and PSK Identity Hint must both be set for client")]
1162 ErrPskAndIdentityMustBeSetForClient,
1163 #[error("SRTP support was requested but server did not respond with use_srtp extension")]
1165 ErrRequestedButNoSrtpExtension,
1166 #[error("Certificate is mandatory for server")]
1168 ErrServerMustHaveCertificate,
1169 #[error("client requested SRTP but we have no matching profiles")]
1171 ErrServerNoMatchingSrtpProfile,
1172 #[error(
1174 "server requires the Extended Master Secret extension, but the client does not support it"
1175 )]
1176 ErrServerRequiredButNoClientEms,
1177 #[error("expected and actual verify data does not match")]
1179 ErrVerifyDataMismatch,
1180 #[error("handshake message unset, unable to marshal")]
1182 ErrHandshakeMessageUnset,
1183 #[error("invalid flight number")]
1185 ErrInvalidFlight,
1186 #[error("unable to generate key signature, unimplemented")]
1188 ErrKeySignatureGenerateUnimplemented,
1189 #[error("unable to verify key signature, unimplemented")]
1191 ErrKeySignatureVerifyUnimplemented,
1192 #[error("data length and declared length do not match")]
1194 ErrLengthMismatch,
1195 #[error("buffer not long enough to contain nonce")]
1197 ErrNotEnoughRoomForNonce,
1198 #[error("feature has not been implemented yet")]
1200 ErrNotImplemented,
1201 #[error("sequence number overflow")]
1203 ErrSequenceNumberOverflow,
1204 #[error("unable to marshal fragmented handshakes")]
1206 ErrUnableToMarshalFragmented,
1207 #[error("invalid state machine transition")]
1209 ErrInvalidFsmTransition,
1210 #[error("ApplicationData with epoch of 0")]
1212 ErrApplicationDataEpochZero,
1213 #[error("unhandled contentType")]
1215 ErrUnhandledContextType,
1216 #[error("context canceled")]
1218 ErrContextCanceled,
1219 #[error("empty fragment")]
1221 ErrEmptyFragment,
1222 #[error("Alert is Fatal or Close Notify")]
1224 ErrAlertFatalOrClose,
1225 #[error("renegotiation_info is not empty in an initial handshake")]
1227 ErrRenegotiationInfoNotEmpty,
1228 #[error("server sent an extension the client did not offer")]
1230 ErrUnsolicitedExtension,
1231 #[error("server selected a compression method the client did not offer")]
1233 ErrCompressionMethodNotOffered,
1234 #[error("client did not offer the null compression method")]
1236 ErrNoNullCompressionMethod,
1237 #[error("server's use_srtp extension is not a valid answer to the client's")]
1240 ErrInvalidUseSrtpAnswer,
1241 #[error("no keying material is exported without the extended master secret")]
1243 ErrExportWithoutExtendedMasterSecret,
1244 #[error("handshake did not complete in time")]
1246 ErrHandshakeTimeout,
1247 #[error("record payload exceeds 2^14 bytes")]
1249 ErrRecordOverflow,
1250 #[error("hello carries an extension type twice")]
1252 ErrDuplicateExtension,
1253 #[error(
1255 "Fragment buffer overflow. New size {new_size} is greater than specified max {max_size}"
1256 )]
1257 ErrFragmentBufferOverflow {
1258 new_size: usize,
1260 max_size: usize,
1262 },
1263 #[error("Client transport is not set yet")]
1265 ErrClientTransportNotSet,
1266
1267 #[error("endpoint stopping")]
1271 EndpointStopping,
1272 #[error("too many connections")]
1276 TooManyConnections,
1277 #[error("invalid DNS name: {0}")]
1279 InvalidDnsName(String),
1280 #[error("invalid remote address: {0}")]
1284 InvalidRemoteAddress(SocketAddr),
1285 #[error("no client config")]
1287 NoClientConfig,
1288 #[error("no server config")]
1290 NoServerConfig,
1291
1292 #[error("raw is too small for a SCTP chunk")]
1295 ErrChunkHeaderTooSmall,
1296 #[error("not enough data left in SCTP packet to satisfy requested length")]
1298 ErrChunkHeaderNotEnoughSpace,
1299 #[error("chunk PADDING is non-zero at offset")]
1301 ErrChunkHeaderPaddingNonZero,
1302 #[error("chunk has invalid length")]
1304 ErrChunkHeaderInvalidLength,
1305
1306 #[error("ChunkType is not of type ABORT")]
1308 ErrChunkTypeNotAbort,
1309 #[error("failed build Abort Chunk")]
1311 ErrBuildAbortChunkFailed,
1312 #[error("ChunkType is not of type COOKIEACK")]
1314 ErrChunkTypeNotCookieAck,
1315 #[error("ChunkType is not of type COOKIEECHO")]
1317 ErrChunkTypeNotCookieEcho,
1318 #[error("ChunkType is not of type ctError")]
1320 ErrChunkTypeNotCt,
1321 #[error("failed build Error Chunk")]
1323 ErrBuildErrorChunkFailed,
1324 #[error("failed to marshal stream")]
1326 ErrMarshalStreamFailed,
1327 #[error("chunk too short")]
1329 ErrChunkTooShort,
1330 #[error("ChunkType is not of type ForwardTsn")]
1332 ErrChunkTypeNotForwardTsn,
1333 #[error("ChunkType is not of type HEARTBEAT")]
1335 ErrChunkTypeNotHeartbeat,
1336 #[error("ChunkType is not of type HEARTBEATACK")]
1338 ErrChunkTypeNotHeartbeatAck,
1339 #[error("heartbeat is not long enough to contain Heartbeat Info")]
1341 ErrHeartbeatNotLongEnoughInfo,
1342 #[error("failed to parse param type")]
1344 ErrParseParamTypeFailed,
1345 #[error("heartbeat should only have HEARTBEAT param")]
1347 ErrHeartbeatParam,
1348 #[error("failed unmarshalling param in Heartbeat Chunk")]
1350 ErrHeartbeatChunkUnmarshal,
1351 #[error("unimplemented")]
1353 ErrUnimplemented,
1354 #[error("heartbeat Ack must have one param")]
1356 ErrHeartbeatAckParams,
1357 #[error("heartbeat Ack must have one param, and it should be a HeartbeatInfo")]
1359 ErrHeartbeatAckNotHeartbeatInfo,
1360 #[error("unable to marshal parameter for Heartbeat Ack")]
1362 ErrHeartbeatAckMarshalParam,
1363
1364 #[error("raw is too small for error cause")]
1366 ErrErrorCauseTooSmall,
1367
1368 #[error("unhandled ParamType: {typ}")]
1370 ErrParamTypeUnhandled {
1371 typ: u16,
1373 },
1374
1375 #[error("unexpected ParamType")]
1377 ErrParamTypeUnexpected,
1378
1379 #[error("param header too short")]
1381 ErrParamHeaderTooShort,
1382 #[error("param self reported length is shorter than header length")]
1384 ErrParamHeaderSelfReportedLengthShorter,
1385 #[error("param self reported length is longer than header length")]
1387 ErrParamHeaderSelfReportedLengthLonger,
1388 #[error("failed to parse param type")]
1390 ErrParamHeaderParseFailed,
1391
1392 #[error("packet to short")]
1394 ErrParamPacketTooShort,
1395 #[error("outgoing SSN reset request parameter too short")]
1397 ErrSsnResetRequestParamTooShort,
1398 #[error("failed unmarshalling SSN reset request parameter in RE-CONFIG chunk")]
1400 ErrUnmarshalSsnResetRequestParam,
1401 #[error("reconfig response parameter too short")]
1403 ErrReconfigRespParamTooShort,
1404 #[error("failed unmarshalling re-configuration response parameter in RE-CONFIG chunk")]
1406 ErrUnmarshalReconfigRespParam,
1407 #[error("invalid algorithm type")]
1409 ErrInvalidAlgorithmType,
1410
1411 #[error("failed to parse param type")]
1413 ErrInitChunkParseParamTypeFailed,
1414 #[error("failed unmarshalling param in Init Chunk")]
1416 ErrInitChunkUnmarshalParam,
1417 #[error("unable to marshal parameter for INIT/INITACK")]
1419 ErrInitAckMarshalParam,
1420
1421 #[error("ChunkType is not of type INIT")]
1423 ErrChunkTypeNotTypeInit,
1424 #[error("chunk Value isn't long enough for mandatory parameters exp")]
1426 ErrChunkValueNotLongEnough,
1427 #[error("ChunkType of type INIT flags must be all 0")]
1429 ErrChunkTypeInitFlagZero,
1430 #[error("failed to unmarshal INIT body")]
1432 ErrChunkTypeInitUnmarshalFailed,
1433 #[error("failed marshaling INIT common data")]
1435 ErrChunkTypeInitMarshalFailed,
1436 #[error("ChunkType of type INIT ACK InitiateTag must not be 0")]
1438 ErrChunkTypeInitInitiateTagZero,
1439 #[error("INIT ACK inbound stream request must be > 0")]
1441 ErrInitInboundStreamRequestZero,
1442 #[error("INIT ACK outbound stream request must be > 0")]
1444 ErrInitOutboundStreamRequestZero,
1445 #[error("INIT ACK Advertised Receiver Window Credit (a_rwnd) must be >= 1500")]
1447 ErrInitAdvertisedReceiver1500,
1448
1449 #[error("packet is smaller than the header size")]
1451 ErrChunkPayloadSmall,
1452 #[error("ChunkType is not of type PayloadData")]
1454 ErrChunkTypeNotPayloadData,
1455 #[error("failed unmarshalling payload data chunk")]
1457 ErrChunkUnmarshalPayloadData,
1458 #[error("ChunkType is not of type Reconfig")]
1460 ErrChunkTypeNotReconfig,
1461 #[error("ChunkReconfig has invalid ParamA")]
1463 ErrChunkReconfigInvalidParamA,
1464
1465 #[error("failed to parse param type")]
1467 ErrChunkParseParamTypeFailed,
1468 #[error("unable to marshal parameter A for reconfig")]
1470 ErrChunkMarshalParamAReconfigFailed,
1471 #[error("unable to marshal parameter B for reconfig")]
1473 ErrChunkMarshalParamBReconfigFailed,
1474
1475 #[error("ChunkType is not of type SACK")]
1477 ErrChunkTypeNotSack,
1478 #[error("SACK Chunk size is not large enough to contain header")]
1480 ErrSackSizeNotLargeEnoughInfo,
1481 #[error("failed unmarshalling SACK chunk")]
1483 ErrChunkUnmarshalSack,
1484
1485 #[error("invalid chunk size")]
1487 ErrInvalidChunkSize,
1488 #[error("ChunkType is not of type SHUTDOWN")]
1490 ErrChunkTypeNotShutdown,
1491 #[error("failed unmarshalling shutdown chunk")]
1493 ErrChunkUnmarshalShutdown,
1494
1495 #[error("ChunkType is not of type SHUTDOWN-ACK")]
1497 ErrChunkTypeNotShutdownAck,
1498 #[error("ChunkType is not of type SHUTDOWN-COMPLETE")]
1500 ErrChunkTypeNotShutdownComplete,
1501
1502 #[error("raw is smaller than the minimum length for a SCTP packet")]
1504 ErrPacketRawTooSmall,
1505 #[error("unable to parse SCTP chunk, not enough data for complete header")]
1507 ErrParseSctpChunkNotEnoughData,
1508 #[error("failed to unmarshal, contains unknown chunk type")]
1510 ErrUnmarshalUnknownChunkType,
1511 #[error("checksum mismatch theirs")]
1513 ErrChecksumMismatch,
1514
1515 #[error("unexpected chunk popped (unordered)")]
1517 ErrUnexpectedChuckPoppedUnordered,
1518 #[error("unexpected chunk popped (ordered)")]
1520 ErrUnexpectedChuckPoppedOrdered,
1521 #[error("unexpected q state (should've been selected)")]
1523 ErrUnexpectedQState,
1524 #[error("try again")]
1526 ErrTryAgain,
1527
1528 #[error("abort chunk, with following errors: {0}")]
1530 ErrAbortChunk(String),
1531 #[error("shutdown called in non-Established state")]
1533 ErrShutdownNonEstablished,
1534 #[error("association closed before connecting")]
1536 ErrAssociationClosedBeforeConn,
1537 #[error("association init failed")]
1539 ErrAssociationInitFailed,
1540 #[error("association handshake closed")]
1542 ErrAssociationHandshakeClosed,
1543 #[error("silently discard")]
1545 ErrSilentlyDiscard,
1546 #[error("the init not stored to send")]
1548 ErrInitNotStoredToSend,
1549 #[error("cookieEcho not stored to send")]
1551 ErrCookieEchoNotStoredToSend,
1552 #[error("sctp packet must not have a source port of 0")]
1554 ErrSctpPacketSourcePortZero,
1555 #[error("sctp packet must not have a destination port of 0")]
1557 ErrSctpPacketDestinationPortZero,
1558 #[error("init chunk must not be bundled with any other chunk")]
1560 ErrInitChunkBundled,
1561 #[error("init chunk expects a verification tag of 0 on the packet when out-of-the-blue")]
1563 ErrInitChunkVerifyTagNotZero,
1564 #[error("todo: handle Init when in state")]
1566 ErrHandleInitState,
1567 #[error("no cookie in InitAck")]
1569 ErrInitAckNoCookie,
1570 #[error("there already exists a stream with identifier")]
1572 ErrStreamAlreadyExist,
1573 #[error("Failed to create a stream with identifier")]
1575 ErrStreamCreateFailed,
1576 #[error("unable to be popped from inflight queue TSN")]
1578 ErrInflightQueueTsnPop,
1579 #[error("requested non-existent TSN")]
1581 ErrTsnRequestNotExist,
1582 #[error("sending reset packet in non-Established state")]
1584 ErrResetPacketInStateNotExist,
1585 #[error("unexpected parameter type")]
1587 ErrParameterType,
1588 #[error("sending payload data in non-Established state")]
1590 ErrPayloadDataStateNotExist,
1591 #[error("unhandled chunk type")]
1593 ErrChunkTypeUnhandled,
1594 #[error("handshake failed (INIT ACK)")]
1596 ErrHandshakeInitAck,
1597 #[error("handshake failed (COOKIE ECHO)")]
1599 ErrHandshakeCookieEcho,
1600
1601 #[error("outbound packet larger than maximum message size")]
1603 ErrOutboundPacketTooLarge,
1604 #[error(
1608 "a {size} byte message is over the {limit} byte limit of an SCTP association without \
1609 message interleaving (RFC 8831 section 6.6: the peer did not announce I-DATA); \
1610 SettingEngineBuilder::with_sctp_message_size_limit_without_interleaving(false) lifts it \
1611 up to the peer's max-message-size"
1612 )]
1613 ErrMessageTooLargeWithoutInterleaving {
1614 size: usize,
1616 limit: u32,
1618 },
1619 #[error("Stream closed")]
1621 ErrStreamClosed,
1622 #[error("Stream not existed")]
1624 ErrStreamNotExisted,
1625 #[error("Association not existed")]
1627 ErrAssociationNotExisted,
1628 #[error("Transport not existed")]
1630 ErrTransportNoExisted,
1631 #[error("Io EOF")]
1633 ErrEof,
1634 #[error("Invalid SystemTime")]
1636 ErrInvalidSystemTime,
1637 #[error("Net Conn read error")]
1639 ErrNetConnRead,
1640 #[error("Max Data Channel ID")]
1642 ErrMaxDataChannelID,
1643
1644 #[error(
1647 "DataChannel message is not long enough to determine type: (expected: {expected}, actual: {actual})"
1648 )]
1649 UnexpectedEndOfBuffer {
1650 expected: usize,
1652 actual: usize,
1654 },
1655 #[error("Unknown MessageType {0}")]
1657 InvalidMessageType(u8),
1658 #[error("Unknown ChannelType {0}")]
1660 InvalidChannelType(u8),
1661 #[error("Unknown PayloadProtocolIdentifier {0}")]
1663 InvalidPayloadProtocolIdentifier(u8),
1664 #[error("Unknow Protocol")]
1666 UnknownProtocol,
1667
1668 #[error("stream is nil")]
1671 ErrNilStream,
1672 #[error("incomplete frame header")]
1674 ErrIncompleteFrameHeader,
1675 #[error("incomplete frame data")]
1677 ErrIncompleteFrameData,
1678 #[error("incomplete file header")]
1680 ErrIncompleteFileHeader,
1681 #[error("IVF signature mismatch")]
1683 ErrSignatureMismatch,
1684 #[error("IVF version unknown, parser may not parse correctly")]
1686 ErrUnknownIVFVersion,
1687
1688 #[error("file not opened")]
1690 ErrFileNotOpened,
1691 #[error("invalid nil packet")]
1693 ErrInvalidNilPacket,
1694
1695 #[error("bad header signature")]
1697 ErrBadIDPageSignature,
1698 #[error("wrong header, expected beginning of stream")]
1700 ErrBadIDPageType,
1701 #[error("payload for id page must be 19 bytes")]
1703 ErrBadIDPageLength,
1704 #[error("bad payload signature")]
1706 ErrBadIDPagePayloadSignature,
1707 #[error("not enough data for payload header")]
1709 ErrShortPageHeader,
1710 #[error("bad OpusTags signature")]
1712 ErrBadOpusTagsSignature,
1713 #[error("unsupported channel mapping family")]
1715 ErrUnsupportedChannelMappingFamily,
1716
1717 #[error("data is not a H264 bitstream")]
1719 ErrDataIsNotH264Stream,
1720 #[error("data is not a H265 bitstream")]
1722 ErrDataIsNotH265Stream,
1723 #[error("Io EOF")]
1725 ErrIoEOF,
1726
1727 #[error("mDNS: port not support, only 5353 is supported")]
1730 ErrMDNSPortNotSupported,
1731 #[error("mDNS: connection is closed")]
1733 ErrMDNSConnectionClosed,
1734 #[error("mDNS: query not found")]
1736 ErrMDNSQueryNotFound,
1737 #[error("mDNS: parsing/packing of this type isn't available yet")]
1739 ErrNotStarted,
1740 #[error("mDNS: parsing/packing of this section has completed")]
1742 ErrSectionDone,
1743 #[error("mDNS: parsing/packing of this section is header")]
1745 ErrSectionHeader,
1746 #[error("mDNS: insufficient data for base length type")]
1748 ErrBaseLen,
1749 #[error("mDNS: insufficient data for calculated length type")]
1751 ErrCalcLen,
1752 #[error("mDNS: segment prefix is reserved")]
1754 ErrReserved,
1755 #[error("mDNS: too many pointers (>10)")]
1757 ErrTooManyPtr,
1758 #[error("mDNS: invalid pointer")]
1760 ErrInvalidPtr,
1761 #[error("mDNS: nil resource body")]
1763 ErrNilResourceBody,
1764 #[error("mDNS: insufficient data for resource body length")]
1766 ErrResourceLen,
1767 #[error("mDNS: segment length too long")]
1769 ErrSegTooLong,
1770 #[error("mDNS: zero length segment")]
1772 ErrZeroSegLen,
1773 #[error("mDNS: resource length too long")]
1775 ErrResTooLong,
1776 #[error("mDNS: too many Questions to pack (>65535)")]
1778 ErrTooManyQuestions,
1779 #[error("mDNS: too many Answers to pack (>65535)")]
1781 ErrTooManyAnswers,
1782 #[error("mDNS: too many Authorities to pack (>65535)")]
1784 ErrTooManyAuthorities,
1785 #[error("mDNS: too many Additionals to pack (>65535)")]
1787 ErrTooManyAdditionals,
1788 #[error("mDNS: name is not in canonical format (it must end with a .)")]
1790 ErrNonCanonicalName,
1791 #[error("mDNS: character string exceeds maximum length (255)")]
1793 ErrStringTooLong,
1794 #[error("mDNS: compressed name in SRV resource data")]
1796 ErrCompressedSrv,
1797 #[error("mDNS: empty builder msg")]
1799 ErrEmptyBuilderMsg,
1800
1801 #[error("connection closed")]
1805 ErrConnectionClosed,
1806
1807 #[error("data channel closed")]
1810 ErrDataChannelClosed,
1811
1812 #[error("data channel is not open yet")]
1816 ErrDataChannelNotOpen,
1817
1818 #[error("data channel stream identifier has not been assigned yet")]
1826 ErrDataChannelStreamIdNotAssigned,
1827
1828 #[error("data channel not existed")]
1831 ErrDataChannelNotExisted,
1832
1833 #[error("data channel send buffer full")]
1837 ErrSendBufferFull,
1838
1839 #[error("x509Cert expired")]
1841 ErrCertificateExpired,
1842
1843 #[error("an ICE server has no url")]
1846 ErrNoIceServerUrls,
1847
1848 #[error("turn server credentials required")]
1851 ErrNoTurnCredentials,
1852
1853 #[error("invalid turn server credentials")]
1856 ErrTurnCredentials,
1857
1858 #[error("track already exists")]
1860 ErrExistingTrack,
1861
1862 #[error("track not existed")]
1864 ErrTrackNotExisted,
1865
1866 #[error("private key type not supported")]
1869 ErrPrivateKeyType,
1870
1871 #[error("peerIdentity cannot be modified")]
1874 ErrModifyingPeerIdentity,
1875
1876 #[error("certificates cannot be modified")]
1879 ErrModifyingCertificates,
1880
1881 #[error("no certificate")]
1883 ErrNonCertificate,
1884
1885 #[error("bundle policy cannot be modified")]
1888 ErrModifyingBundlePolicy,
1889
1890 #[error("rtcp mux policy cannot be modified")]
1893 ErrModifyingRTCPMuxPolicy,
1894
1895 #[error("ice candidate pool size cannot be modified")]
1898 ErrModifyingICECandidatePoolSize,
1899
1900 #[error("data channel label exceeds size limit")]
1903 ErrStringSizeLimit,
1904
1905 #[error("negotiated set without channel id")]
1909 ErrNegotiatedWithoutID,
1910
1911 #[error("both max_packet_life_time and max_retransmits was set")]
1916 ErrRetransmitsOrPacketLifeTime,
1917
1918 #[error("codec not found")]
1920 ErrCodecNotFound,
1921
1922 #[error("remote description is not set")]
1925 ErrNoRemoteDescription,
1926
1927 #[error(
1930 "no media section of the remote description matches the candidate's sdpMid or sdpMLineIndex"
1931 )]
1932 ErrIceCandidateMediaSectionNotFound,
1933
1934 #[error("the candidate's usernameFragment is not its media section's ice-ufrag")]
1937 ErrIceCandidateUsernameFragmentMismatch,
1938
1939 #[error(
1943 "set_remote_description called with an ice-ufrag or ice-pwd that isn't RFC 8839 syntax"
1944 )]
1945 ErrSessionDescriptionInvalidIceCredentials,
1946
1947 #[error("offer SDP semantics does not match configuration")]
1950 ErrIncorrectSDPSemantics,
1951
1952 #[error("operation can not be run in current signaling state")]
1954 ErrIncorrectSignalingState,
1955
1956 #[error("protocol is larger then 65535 bytes")]
1959 ErrProtocolTooLarge,
1960
1961 #[error("label is larger than 65535 bytes")]
1964 ErrLabelTooLarge,
1965
1966 #[error("the {0} replay window of {1} packets is below the 64 RFC 3711 requires")]
1968 ErrSrtpReplayWindowTooSmall(&'static str, usize),
1969
1970 #[error("OperationError: {0}")]
1972 ErrOperationError(String),
1973
1974 #[error("{0:?} is not a DTMF tone")]
1976 ErrDtmfInvalidCharacter(char),
1977
1978 #[error("the data channel's send buffer is full")]
1981 ErrDataChannelBufferFull,
1982
1983 #[error("the data channel id is not below the SCTP transport's maxChannels")]
1986 ErrDataChannelIdAboveMaxChannels,
1987
1988 #[error("data channel id is already in use")]
1991 ErrDataChannelIdInUse,
1992
1993 #[error("RtpSender not created by this PeerConnection")]
1996 ErrSenderNotCreatedByConnection,
1997
1998 #[error("RtpSender's initial_track_id has already been set")]
2001 ErrSenderInitialTrackIdAlreadySet,
2002
2003 #[error("set_remote_description called with no fingerprint")]
2006 ErrSessionDescriptionNoFingerprint,
2007
2008 #[error("set_remote_description called with an invalid fingerprint")]
2011 ErrSessionDescriptionInvalidFingerprint,
2012
2013 #[error("set_remote_description called with multiple conflicting fingerprint")]
2016 ErrSessionDescriptionConflictingFingerprints,
2017
2018 #[error("set_remote_description called with an invalid setup attribute")]
2022 ErrSessionDescriptionInvalidSetup,
2023
2024 #[error("set_remote_description called with an invalid tls-id attribute")]
2028 ErrSessionDescriptionInvalidTlsId,
2029
2030 #[error("invalid identity assertion")]
2032 ErrInvalidIdentityAssertion,
2033
2034 #[error("set_remote_description called with no ice-ufrag")]
2037 ErrSessionDescriptionMissingIceUfrag,
2038
2039 #[error("set_remote_description called with no ice-pwd")]
2042 ErrSessionDescriptionMissingIcePwd,
2043
2044 #[error("set_remote_description called with multiple conflicting ice-ufrag values")]
2047 ErrSessionDescriptionConflictingIceUfrag,
2048
2049 #[error("set_remote_description called with multiple conflicting ice-pwd values")]
2052 ErrSessionDescriptionConflictingIcePwd,
2053
2054 #[error("set_remote_description called without a=cryptex while header encryption is required")]
2058 ErrSessionDescriptionMissingCryptex,
2059
2060 #[error("DTLS Handshake completed and no SRTP Protection Profile was chosen")]
2062 ErrNoSRTPProtectionProfile,
2063
2064 #[error("failed to generate certificate fingerprint")]
2066 ErrFailedToGenerateCertificateFingerprint,
2067
2068 #[error("operation failed no codecs are available")]
2070 ErrNoCodecsAvailable,
2071
2072 #[error("unable to start track, codec is not supported by remote")]
2074 ErrUnsupportedCodec,
2075
2076 #[error("Invalid state error")]
2078 InvalidStateError,
2079
2080 #[error("Invalid modification error")]
2082 InvalidModificationError,
2083
2084 #[error("Not found error")]
2087 NotFoundError,
2088
2089 #[error("Invalid access error")]
2093 InvalidAccessError,
2094
2095 #[error("Range error {0}")]
2097 RangeError(String),
2098
2099 #[error("Type error {0}")]
2101 TypeError(String),
2102
2103 #[error("Overconstrained: {0}")]
2107 OverconstrainedError(String),
2108
2109 #[error("SFrame was offered and the answer refused it: no media is sent")]
2112 ErrSFrameRefused,
2113
2114 #[error("SDP syntax error{}: {error}", .line_number.map(|n| format!(" on line {n}")).unwrap_or_default())]
2117 SdpSyntaxError {
2118 line_number: Option<usize>,
2120 error: Box<Error>,
2122 },
2123
2124 #[error("unable to populate media section, RTPSender created with no codecs")]
2127 ErrSenderWithNoCodecs,
2128
2129 #[error("unable to populate media section, RTPSender created with no ssrcs")]
2132 ErrSenderWithNoSSRCs,
2133
2134 #[error("new track must be of the same kind as previous")]
2136 ErrRTPSenderNewTrackHasIncorrectKind,
2137
2138 #[error("new track has incorrect envelope")]
2140 ErrRTPSenderNewTrackHasIncorrectEnvelope,
2141
2142 #[error("Sequence number transformer must be enabled before sending data")]
2144 ErrRTPSenderDataSent,
2145
2146 #[error("Sequence number transformer has been already enabled")]
2148 ErrRTPSenderSeqTransEnabled,
2149
2150 #[error("failed to unbind TrackLocal from PeerConnection")]
2152 ErrUnbindFailed,
2153
2154 #[error("the requested codec does not have a payloader")]
2156 ErrNoPayloaderForCodec,
2157
2158 #[error("a header extension must be registered with the same direction each time")]
2161 ErrRegisterHeaderExtensionInvalidDirection,
2162
2163 #[error("invalid direction")]
2165 ErrInvalidDirection,
2166
2167 #[error(
2171 "no header extension ID was free to use (the maximum of 254 extensions have been registered)"
2172 )]
2173 ErrRegisterHeaderExtensionNoFreeID,
2174
2175 #[error("simulcast probe limit has been reached, new SSRC has been discarded")]
2177 ErrSimulcastProbeOverflow,
2178
2179 #[error("enable detaching by calling webrtc.DetachDataChannels()")]
2181 ErrDetachNotEnabled,
2182 #[error("datachannel not opened yet, try calling Detach from OnOpen")]
2184 ErrDetachBeforeOpened,
2185 #[error("the DTLS transport has not started yet")]
2187 ErrDtlsTransportNotStarted,
2188 #[error("failed extracting keys from DTLS for SRTP")]
2190 ErrDtlsKeyExtractionFailed,
2191 #[error("failed to start SRTP")]
2193 ErrFailedToStartSRTP,
2194 #[error("failed to start SRTCP")]
2196 ErrFailedToStartSRTCP,
2197 #[error("attempted to start DTLSTransport that is not in new state")]
2199 ErrInvalidDTLSStart,
2200 #[error("peer didn't provide certificate via DTLS")]
2202 ErrNoRemoteCertificate,
2203 #[error("identity provider is not implemented")]
2205 ErrIdentityProviderNotImplemented,
2206 #[error("remote certificate does not match any fingerprint")]
2208 ErrNoMatchingCertificateFingerprint,
2209 #[error("unsupported fingerprint algorithm")]
2211 ErrUnsupportedFingerprintAlgorithm,
2212 #[error("ICE connection not started")]
2214 ErrICEConnectionNotStarted,
2215 #[error("unknown candidate type")]
2217 ErrICECandidateTypeUnknown,
2218 #[error("cannot convert ice.CandidateType into webrtc.ICECandidateType, invalid type")]
2220 ErrICEInvalidConvertCandidateType,
2221 #[error("ICEAgent does not exist")]
2223 ErrICEAgentNotExist,
2224 #[error("unable to convert ICE candidates to ICECandidates")]
2226 ErrICECandidatesConversionFailed,
2227 #[error("unknown ICE Role")]
2229 ErrICERoleUnknown,
2230 #[error("unknown protocol")]
2232 ErrICEProtocolUnknown,
2233 #[error("gatherer not started")]
2235 ErrICEGathererNotStarted,
2236 #[error("unknown network type")]
2238 ErrNetworkTypeUnknown,
2239 #[error("new sdp does not match previous offer")]
2241 ErrSDPDoesNotMatchOffer,
2242 #[error("new sdp does not match previous answer")]
2244 ErrSDPDoesNotMatchAnswer,
2245 #[error("the answer does not match the offer: {0}")]
2248 ErrAnswerDoesNotMatchOffer(String),
2249 #[error("provided value is not a valid enum value of type SDPType")]
2251 ErrPeerConnSDPTypeInvalidValue,
2252 #[error("invalid state change op")]
2254 ErrPeerConnStateChangeInvalid,
2255 #[error("unhandled state change op")]
2257 ErrPeerConnStateChangeUnhandled,
2258 #[error("invalid SDP type supplied to SetLocalDescription()")]
2260 ErrPeerConnSDPTypeInvalidValueSetLocalDescription,
2261 #[error("remoteDescription contained media section without mid value")]
2263 ErrPeerConnRemoteDescriptionWithoutMidValue,
2264 #[error("localDescription contained media section without mid value")]
2266 ErrPeerConnLocalDescriptionWithoutMidValue,
2267 #[error("remoteDescription has not been set yet")]
2269 ErrPeerConnRemoteDescriptionNil,
2270 #[error("localDescription has not been set yet")]
2272 ErrPeerConnLocalDescriptionNil,
2273 #[error("single media section has an explicit SSRC")]
2275 ErrPeerConnSingleMediaSectionHasExplicitSSRC,
2276 #[error("could not add transceiver for remote SSRC")]
2278 ErrPeerConnRemoteSSRCAddTransceiver,
2279 #[error("mid RTP Extensions required for Simulcast")]
2281 ErrPeerConnSimulcastMidRTPExtensionRequired,
2282 #[error("stream id RTP Extensions required for Simulcast")]
2284 ErrPeerConnSimulcastStreamIDRTPExtensionRequired,
2285 #[error("incoming SSRC failed Simulcast probing")]
2287 ErrPeerConnSimulcastIncomingSSRCFailed,
2288 #[error("failed collecting stats")]
2290 ErrPeerConnStatsCollectionFailed,
2291 #[error("add_transceiver_from_kind only accepts one RTPTransceiverInit")]
2293 ErrPeerConnAddTransceiverFromKindOnlyAcceptsOne,
2294 #[error("add_transceiver_from_track only accepts one RTPTransceiverInit")]
2296 ErrPeerConnAddTransceiverFromTrackOnlyAcceptsOne,
2297 #[error("add_transceiver_from_kind currently only supports recvonly")]
2299 ErrPeerConnAddTransceiverFromKindSupport,
2300 #[error("add_transceiver_from_track currently only supports sendonly and sendrecv")]
2302 ErrPeerConnAddTransceiverFromTrackSupport,
2303 #[error("TODO set_identity_provider")]
2305 ErrPeerConnSetIdentityProviderNotImplemented,
2306 #[error("write_rtcp failed to open write_stream")]
2308 ErrPeerConnWriteRTCPOpenWriteStream,
2309 #[error("cannot find transceiver with mid")]
2311 ErrPeerConnTransceiverMidNil,
2312 #[error("DTLSTransport must not be nil")]
2314 ErrRTPReceiverDTLSTransportNil,
2315 #[error("Receive has already been called")]
2317 ErrRTPReceiverReceiveAlreadyCalled,
2318 #[error("unable to find stream for Track with SSRC")]
2320 ErrRTPReceiverWithSSRCTrackStreamNotFound,
2321 #[error("no trackStreams found for SSRC")]
2323 ErrRTPReceiverForSSRCTrackStreamNotFound,
2324 #[error("no trackStreams found for RID")]
2326 ErrRTPReceiverForRIDTrackStreamNotFound,
2327 #[error("invalid RTP Receiver transition")]
2329 ErrRTPReceiverStateChangeInvalid,
2330 #[error("Track must not be nil")]
2332 ErrRTPSenderTrackNil,
2333 #[error("RTPSender not existed")]
2335 ErrRTPSenderNotExisted,
2336 #[error("Sender Track has been removed or replaced to nil")]
2338 ErrRTPSenderTrackRemoved,
2339 #[error("Sender cannot add encoding as rid is empty")]
2341 ErrRTPSenderRidNil,
2342 #[error("no a=imageattr line of the remote description can be satisfied")]
2346 ErrImageAttrUnsatisfiable,
2347 #[error("Sender cannot add encoding as there is no base track")]
2349 ErrRTPSenderNoBaseEncoding,
2350 #[error("Sender cannot add encoding as provided track does not match base track")]
2352 ErrRTPSenderBaseEncodingMismatch,
2353 #[error("Sender cannot encoding due to RID collision")]
2355 ErrRTPSenderRIDCollision,
2356 #[error("sender encodings name SSRC {0} for more than one stream")]
2360 ErrRTPSenderSsrcCollision(u32),
2361 #[error("RTCP feedback `{0} {1}` was not negotiated for the stream")]
2364 ErrRTCPFeedbackNotNegotiated(String, String),
2365 #[error("Sender cannot add encoding as its rid is not 1 to 255 alphanumeric characters")]
2368 ErrRTPSenderRidInvalid,
2369 #[error("Sender cannot use SSRC {0}: another local stream has it")]
2373 ErrRTPSenderSsrcTaken(u32),
2374 #[error("the remote description carries no identity assertion")]
2377 ErrNoRemoteIdentityAssertion,
2378 #[error("the verified identity does not cover every fingerprint of the remote description")]
2381 ErrIdentityFingerprintsNotCovered,
2382 #[error("the certificate in use is not among the fingerprints of the verified identity")]
2385 ErrIdentityCertificateNotCovered,
2386 #[error("Sender does not have track for RID")]
2388 ErrRTPSenderNoTrackForRID,
2389 #[error("RTPReceiver not existed")]
2391 ErrRTPReceiverNotExisted,
2392 #[error("DTLSTransport must not be nil")]
2394 ErrRTPSenderDTLSTransportNil,
2395 #[error("Send has already been called")]
2397 ErrRTPSenderSendAlreadyCalled,
2398 #[error("RTPTransceiver not existed")]
2400 ErrRTPTransceiverNotExisted,
2401 #[error("SCTPTransport not existed")]
2403 ErrSCTPTransportNotExisted,
2404 #[error("DTLSTransport not existed")]
2406 ErrDTLSTransportNotExisted,
2407 #[error("errRTPSenderTrackNil")]
2409 ErrRTPTransceiverCannotChangeMid,
2410 #[error("invalid state change in RTPTransceiver.setSending")]
2412 ErrRTPTransceiverSetSendingInvalidState,
2413 #[error("unsupported codec type by this transceiver")]
2415 ErrRTPTransceiverCodecUnsupported,
2416 #[error("DTLS not established")]
2418 ErrSCTPTransportDTLS,
2419 #[error("add_transceiver_sdp() called with 0 transceivers")]
2421 ErrSDPZeroTransceivers,
2422 #[error("invalid Media Section. Data channel section without a valid a=sctp-port")]
2424 ErrSDPSctpPortInvalid,
2425 #[error("invalid Media Section. Media + DataChannel both enabled")]
2427 ErrSDPMediaSectionMediaDataChanInvalid,
2428 #[error("invalid Media Section Track Index")]
2430 ErrSDPMediaSectionTrackInvalid,
2431 #[error("can't rollback from stable state")]
2433 ErrSignalingStateCannotRollback,
2434 #[error("invalid proposed signaling state transition: {0}")]
2436 ErrSignalingStateProposedTransitionInvalid(String),
2437 #[error("cannot convert to StatsICECandidatePairStateSucceeded invalid ice candidate state")]
2439 ErrStatsICECandidateStateInvalid,
2440 #[error("ICETransport can only be called in ICETransportStateNew")]
2442 ErrICETransportNotInNew,
2443 #[error(
2446 "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)"
2447 )]
2448 ErrICECandidateAddressOfPreviousDtlsAssociation(std::net::SocketAddr),
2449 #[error("bad Certificate PEM format")]
2451 ErrCertificatePEMFormatError,
2452 #[error("SCTP is not established")]
2454 ErrSCTPNotEstablished,
2455
2456 #[error("DataChannel is not opened")]
2458 ErrClosedPipe,
2459 #[error("Interceptor is not bind")]
2461 ErrInterceptorNotBind,
2462 #[error("excessive retries in CreateOffer")]
2464 ErrExcessiveRetries,
2465
2466 #[error("not long enough to be a RTP Packet")]
2468 ErrRTPTooShort,
2469
2470 #[error("RFC8851 mandates rid-syntax = %s\"a=rid:\" rid-id SP rid-dir")]
2472 SimulcastRidParseErrorSyntaxIdDirSplit,
2473 #[error("RFC8851 mandates rid-dir = %s\"send\" / %s\"recv\"")]
2475 SimulcastRidParseErrorUnknownDirection,
2476
2477 #[error("codec not found")]
2480 CodecNotFound,
2481 #[error("missing whitespace")]
2483 MissingWhitespace,
2484 #[error("missing colon")]
2486 MissingColon,
2487 #[error("payload type not found")]
2489 PayloadTypeNotFound,
2490 #[error("SdpInvalidSyntax: {0}")]
2492 SdpInvalidSyntax(String),
2493 #[error("SdpInvalidValue: {0}")]
2495 SdpInvalidValue(String),
2496 #[error("sdp: empty time_descriptions")]
2498 SdpEmptyTimeDescription,
2499 #[error("parse extmap: {0}")]
2501 ParseExtMap(String),
2502 #[error("{} --> {} <-- {}", .s.substring(0,*.p), .s.substring(*.p, *.p+1), .s.substring(*.p+1, .s.len())
2504 )]
2505 SyntaxError {
2506 s: String,
2508 p: usize,
2510 },
2511
2512 #[error("invalid PEM: {0}")]
2515 InvalidPEM(String),
2516 #[error("parse ip: {0}")]
2518 ParseIp(#[from] net::AddrParseError),
2519 #[error("parse int: {0}")]
2521 ParseInt(#[from] ParseIntError),
2522 #[error("{0}")]
2524 Io(#[source] IoError),
2525 #[error("url parse: {0}")]
2527 Url(#[from] url::ParseError),
2528 #[error("utf8: {0}")]
2530 Utf8(#[from] FromUtf8Error),
2531 #[error("{0}")]
2533 Std(#[source] StdError),
2534 #[error("Other RTCP Err: {0}")]
2537 OtherRtcpErr(String),
2538 #[error("Other RTP Err: {0}")]
2540 OtherRtpErr(String),
2541 #[error("Other SRTP Err: {0}")]
2543 OtherSrtpErr(String),
2544 #[error("Other STUN Err: {0}")]
2546 OtherStunErr(String),
2547 #[error("Other TURN Err: {0}")]
2549 OtherTurnErr(String),
2550 #[error("Other ICE Err: {0}")]
2552 OtherIceErr(String),
2553 #[error("Other DTLS Err: {0}")]
2555 OtherDtlsErr(String),
2556 #[error("Other SCTP Err: {0}")]
2558 OtherSctpErr(String),
2559 #[error("Other DataChannel Err: {0}")]
2561 OtherDataChannelErr(String),
2562 #[error("Other Interceptor Err: {0}")]
2564 OtherInterceptorErr(String),
2565 #[error("Other Media Err: {0}")]
2567 OtherMediaErr(String),
2568 #[error("Other mDNS Err: {0}")]
2570 OtherMdnsErr(String),
2571 #[error("Other SDP Err: {0}")]
2573 OtherSdpErr(String),
2574 #[error("Other PeerConnection Err: {0}")]
2576 OtherPeerConnectionErr(String),
2577 #[error("crypto: {0}")]
2579 Crypto(String),
2580 #[error("stream: unknown connection or listener")]
2583 ErrUnknownStream,
2584 #[error("stream: connection closed")]
2586 ErrStreamConnectionClosed,
2587 #[error("stream: message too long for its framing")]
2590 ErrStreamMessageTooLong,
2591 #[error("{0}")]
2592 Other(String),
2594}
2595
2596impl Error {
2597 pub fn from_std<T>(error: T) -> Self
2600 where
2601 T: std::error::Error + Send + Sync + 'static,
2602 {
2603 Error::Std(StdError(Box::new(error)))
2604 }
2605
2606 pub fn dom_exception_name(&self) -> Option<&'static str> {
2620 match self {
2621 Error::SdpSyntaxError { .. } | Error::SdpInvalidSyntax(_) => Some("OperationError"),
2622 Error::InvalidAccessError
2623 | Error::SdpInvalidValue(_)
2624 | Error::ErrPeerConnRemoteDescriptionWithoutMidValue
2625 | Error::ErrSessionDescriptionInvalidIceCredentials
2626 | Error::ErrSessionDescriptionNoFingerprint
2627 | Error::ErrSessionDescriptionInvalidFingerprint
2628 | Error::ErrSessionDescriptionConflictingFingerprints
2629 | Error::ErrSessionDescriptionInvalidSetup
2630 | Error::ErrSessionDescriptionInvalidTlsId
2631 | Error::ErrSessionDescriptionMissingIceUfrag
2632 | Error::ErrSessionDescriptionMissingIcePwd
2633 | Error::ErrSessionDescriptionConflictingIceUfrag
2634 | Error::ErrSessionDescriptionConflictingIcePwd
2635 | Error::ErrSessionDescriptionMissingCryptex => Some("InvalidAccessError"),
2636 Error::InvalidStateError
2637 | Error::ErrConnectionClosed
2638 | Error::ErrIncorrectSignalingState
2639 | Error::ErrSignalingStateCannotRollback
2640 | Error::ErrSignalingStateProposedTransitionInvalid(_) => Some("InvalidStateError"),
2641 Error::InvalidModificationError => Some("InvalidModificationError"),
2642 Error::NotFoundError => Some("NotFoundError"),
2643 Error::RangeError(_) => Some("RangeError"),
2644 Error::TypeError(_) => Some("TypeError"),
2645 Error::OverconstrainedError(_) => Some("OverconstrainedError"),
2646 _ => None,
2647 }
2648 }
2649
2650 pub fn rtc_error_detail(&self) -> Option<&'static str> {
2653 match self {
2654 Error::SdpSyntaxError { .. } | Error::SdpInvalidSyntax(_) => Some("sdp-syntax-error"),
2655 _ => None,
2656 }
2657 }
2658
2659 pub fn downcast_ref<T: std::error::Error + 'static>(&self) -> Option<&T> {
2664 if let Error::Std(s) = self {
2665 return s.0.downcast_ref();
2666 }
2667
2668 None
2669 }
2670}
2671
2672#[derive(Debug, Error)]
2678#[error("io error: {0}")]
2679pub struct IoError(#[from] pub io::Error);
2680
2681impl PartialEq for IoError {
2683 fn eq(&self, other: &Self) -> bool {
2684 self.0.kind() == other.0.kind()
2685 }
2686}
2687
2688impl From<io::Error> for Error {
2689 fn from(e: io::Error) -> Self {
2690 Error::Io(IoError(e))
2691 }
2692}
2693
2694#[derive(Debug, Error)]
2704#[error("{0}")]
2705pub struct StdError(pub Box<dyn std::error::Error + Send + Sync>);
2706
2707impl PartialEq for StdError {
2708 fn eq(&self, _: &Self) -> bool {
2709 false
2710 }
2711}
2712
2713impl<T> From<std::sync::PoisonError<T>> for Error {
2714 fn from(e: std::sync::PoisonError<T>) -> Self {
2715 Error::PoisonError(e.to_string())
2716 }
2717}
2718
2719impl From<SystemTimeError> for Error {
2720 fn from(e: SystemTimeError) -> Self {
2721 Error::Other(e.to_string())
2722 }
2723}
2724
2725pub fn flatten_errs(errs: Vec<impl Into<Error>>) -> Result<()> {
2729 if errs.is_empty() {
2730 Ok(())
2731 } else {
2732 let errs_strs: Vec<String> = errs.into_iter().map(|e| e.into().to_string()).collect();
2733 Err(Error::Other(errs_strs.join("\n")))
2734 }
2735}