跳到主要内容

Error

搜索

枚举 Error 

源代码
#[non_exhaustive]
pub enum Error {
Show 22 variants InappropriateMessage { expect_types: Vec<ContentType>, got_type: ContentType, }, InappropriateHandshakeMessage { expect_types: Vec<HandshakeType>, got_type: HandshakeType, }, InvalidEncryptedClientHello(EncryptedClientHelloError), InvalidMessage(InvalidMessage), NoCertificatesPresented, UnsupportedNameType, DecryptError, EncryptError, PeerIncompatible(PeerIncompatible), PeerMisbehaved(PeerMisbehaved), AlertReceived(AlertDescription), InvalidCertificate(CertificateError), InvalidCertRevocationList(CertRevocationListError), General(String), FailedToGetCurrentTime, FailedToGetRandomBytes, HandshakeNotComplete, PeerSentOversizedRecord, NoApplicationProtocol, BadMaxFragmentSize, InconsistentKeys(InconsistentKeys), Other(OtherError),
}
展开描述

rustls 通过该类型上报协议错误。

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
非穷尽枚举将来可能添加额外的变体。因此,在对非穷尽枚举的变体进行模式匹配时,必须额外添加一个通配分支以容纳未来可能新增的变体。
§

InappropriateMessage

我们收到了此刻并不合法的 TLS 消息。expect_types 列出当前阶段预期可能出现的消息类型;got_type 则是我们实际收到的类型。此错误通常由 TLS 协议栈存在 bug(对端或本端)、网络故障或攻击所致。

字段

§expect_types: Vec<ContentType>

我们预期收到的类型

§got_type: ContentType

我们实际收到的类型

§

InappropriateHandshakeMessage

我们收到了此刻并不合法的 TLS 握手消息。expect_types 列出当前阶段预期可能出现的握手消息类型;got_type 则是我们实际收到的类型。

字段

§expect_types: Vec<HandshakeType>

我们预期收到的握手消息类型

§got_type: HandshakeType

我们实际收到的握手消息类型

§

InvalidEncryptedClientHello(EncryptedClientHelloError)

处理 ECH(Encrypted Client Hello)时发生错误。

§

InvalidMessage(InvalidMessage)

对端发来了内容非法的 TLS 消息。

§

NoCertificatesPresented

对端未提供任何证书。

§

UnsupportedNameType

证书验证器不支持所给名称的类型。

§

DecryptError

无法解密某条消息。此错误总是致命的。

§

EncryptError

由于消息大小超过允许上限,我们无法对其进行加密。只要应用程序使用了合法的记录大小,此错误就绝不会发生。

§

PeerIncompatible(PeerIncompatible)

对端不支持我们所需的某个协议版本或特性。参数给出具体是哪个版本或特性的提示。

§

PeerMisbehaved(PeerMisbehaved)

对端偏离了标准 TLS 协议。参数给出偏差位置的提示。

§

AlertReceived(AlertDescription)

我们收到了致命告警。这表示对端不满意。

§

InvalidCertificate(CertificateError)

发现了一张非法证书。

其中包含的错误来自证书验证 trait 的实现。

§

InvalidCertRevocationList(CertRevocationListError)

所提供的证书吊销列表(CRL)无效。

§

General(String)

用于兜底处理不太可能出现的错误。

§

FailedToGetCurrentTime

无法获取当前时间。

§

FailedToGetRandomBytes

无法从系统获取随机字节。

§

HandshakeNotComplete

在 TLS 握手完成之前,该函数无法使用。

§

PeerSentOversizedRecord

对端发送了过大的记录或分片。

§

NoApplicationProtocol

入站连接不支持任何已知的应用层协议。

§

BadMaxFragmentSize

配置中提供的 max_fragment_size 值过小或过大。

§

InconsistentKeys(InconsistentKeys)

来自 keys_match 或无法产生对应公钥的 crate::crypto::signer::SigningKey 的特定失败情形。

§

Other(OtherError)

任何其他错误。

此变体应仅在错误无法被更具体的变体准确描述时使用。例如,自定义加密提供者返回的特定错误。

持有此变体的枚举值之间永远不会判等。

trait 实现§

源代码§

impl Clone for Error

源代码§

fn clone(&self) -> Error

返回值的副本。 更多信息
1.0.0 · 源代码§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 更多信息
源代码§

impl Debug for Error

源代码§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

使用给定的格式化器格式化此值。 更多信息
源代码§

impl Display for Error

源代码§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

使用给定的格式化器格式化此值。 更多信息
源代码§

impl Error for Error

Available on crate feature std only.
1.30.0 · 源代码§

fn source(&self) -> Option<&(dyn Error + 'static)>

返回此错误的更底层来源(若有)。 更多信息
1.0.0 · 源代码§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · 源代码§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
源代码§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. 更多信息
源代码§

impl From<CertRevocationListError> for Error

源代码§

fn from(e: CertRevocationListError) -> Error

从输入类型转换为此类型。
源代码§

impl From<CertificateError> for Error

源代码§

fn from(e: CertificateError) -> Error

从输入类型转换为此类型。
源代码§

impl From<EncryptedClientHelloError> for Error

源代码§

fn from(e: EncryptedClientHelloError) -> Error

从输入类型转换为此类型。
源代码§

impl From<GetRandomFailed> for Error

源代码§

fn from(_: GetRandomFailed) -> Error

从输入类型转换为此类型。
源代码§

impl From<InconsistentKeys> for Error

源代码§

fn from(e: InconsistentKeys) -> Error

从输入类型转换为此类型。
源代码§

impl From<InvalidMessage> for Error

源代码§

fn from(e: InvalidMessage) -> Error

从输入类型转换为此类型。
源代码§

impl From<OtherError> for Error

源代码§

fn from(value: OtherError) -> Error

从输入类型转换为此类型。
源代码§

impl From<PeerIncompatible> for Error

源代码§

fn from(e: PeerIncompatible) -> Error

从输入类型转换为此类型。
源代码§

impl From<PeerMisbehaved> for Error

源代码§

fn from(e: PeerMisbehaved) -> Error

从输入类型转换为此类型。
源代码§

impl From<SystemTimeError> for Error

Available on crate feature std only.
源代码§

fn from(_: SystemTimeError) -> Error

从输入类型转换为此类型。
源代码§

impl From<UnsupportedOperationError> for Error

源代码§

fn from(value: UnsupportedOperationError) -> Error

从输入类型转换为此类型。
源代码§

impl PartialEq for Error

源代码§

fn eq(&self, other: &Error) -> bool

测试 selfother 值是否相等,供 == 运算符使用。
1.0.0 · 源代码§

fn ne(&self, other: &Rhs) -> bool

测试 != 运算符。默认实现几乎总是够用,除非有非常充分的理由,否则不应被覆盖。
源代码§

impl StructuralPartialEq for Error

自动 trait 实现§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl !UnwindSafe for Error

blanket 实现§

源代码§

impl<T> Any for T
where T: 'static + ?Sized,

源代码§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
源代码§

impl<T> Borrow<T> for T
where T: ?Sized,

源代码§

fn borrow(&self) -> &T

Immutably borrows from an owned value. 更多信息
源代码§

impl<T> BorrowMut<T> for T
where T: ?Sized,

源代码§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 更多信息
源代码§

impl<T> CloneToUninit for T
where T: Clone,

源代码§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 更多信息
源代码§

impl<T> From<T> for T

源代码§

fn from(t: T) -> T

原样返回该参数。

源代码§

impl<T> Instrument for T

源代码§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. 更多信息
源代码§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. 更多信息
源代码§

impl<T, U> Into<U> for T
where U: From<T>,

源代码§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换行为完全由 From<T> for U 的实现决定。

源代码§

impl<T> ToOwned for T
where T: Clone,

源代码§

type Owned = T

获得所有权后的类型。
源代码§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. 更多信息
源代码§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 更多信息
源代码§

impl<T> ToString for T
where T: Display + ?Sized,

源代码§

fn to_string(&self) -> String

Converts the given value to a String. 更多信息
源代码§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

源代码§

type Error = Infallible

转换出错时返回的类型。
源代码§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
源代码§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

源代码§

type Error = <U as TryFrom<T>>::Error

转换出错时返回的类型。
源代码§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。
源代码§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

源代码§

fn vzip(self) -> V

源代码§

impl<T> WithSubscriber for T

源代码§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. 更多信息
源代码§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. 更多信息
源代码§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

源代码§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

源代码§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,