Struct taos_error::Error

source ·
pub struct Error { /* private fields */ }

Implementations§

Examples found in repository?
src/lib.rs (line 123)
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
    fn from(dsn: DsnError) -> Self {
        Self::new(Code::Failed, dsn.to_string())
    }
}

pub type Result<T> = std::result::Result<T, Error>;

impl Error {
    #[inline]
    pub fn new(code: impl Into<Code>, err: impl Into<Cow<'static, str>>) -> Self {
        Self {
            code: code.into(),
            err: err.into(),
            #[cfg(nightly)]
            #[cfg_attr(nightly, no_coverage)]
            backtrace: Backtrace::capture(),
        }
    }

    #[inline]
    pub fn errno(&self) -> Code {
        self.code
    }

    #[inline]
    pub const fn code(&self) -> Code {
        self.code
    }
    #[inline]
    pub fn message(&self) -> &str {
        &self.err
    }

    #[inline]
    pub fn from_code(code: impl Into<Code>) -> Self {
        Self::new(code, "")
    }

    #[inline]
    pub fn from_string(err: impl Into<Cow<'static, str>>) -> Self {
        Self::new(Code::Failed, err)
    }

    #[inline]
    pub fn from_any(err: impl Display) -> Self {
        Self::new(Code::Failed, err.to_string())
    }
Examples found in repository?
src/lib.rs (line 176)
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
        Ok(Self::from_string(s.to_string()))
    }
}

impl Display for Error {
    #[inline]
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        if self.code == Code::Failed {
            write!(f, "{}", self.err)
        } else {
            write!(f, "[{:#06X}] {}", self.code, self.err)
        }
    }
}

#[cfg(feature = "serde")]
impl serde::de::Error for Error {
    #[inline]
    fn custom<T: fmt::Display>(msg: T) -> Error {
        Error::from_string(format!("{}", msg))
    }

Trait Implementations§

Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The lower-level source of this error, if any. Read more
👎Deprecated since 1.42.0: use the Display impl or to_string()
👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
Raised when there is general error when deserializing a type. Read more
Raised when a Deserialize receives a type different from what it was expecting. Read more
Raised when a Deserialize receives a value of the right type but that is wrong for some other reason. Read more
Raised when deserializing a sequence or map and the input data contains too many or too few elements. Read more
Raised when a Deserialize enum type received a variant with an unrecognized name.
Raised when a Deserialize struct type received a field with an unrecognized name.
Raised when a Deserialize struct type expected to receive a required field with a particular name but that field was not present in the input.
Raised when a Deserialize struct type received more than one of the same field.
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

🔬This is a nightly-only experimental API. (provide_any)
Data providers should implement this method to provide all values they are able to provide by using demand. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.