rust_icu_common

Enum Error

Source
pub enum Error {
    Sys(UErrorCode),
    Wrapper(Error),
}
Expand description

Represents a Unicode error, resulting from operations of low-level ICU libraries.

This is modeled after absl::Status in the Abseil library, which provides ways for users to avoid dealing with all the numerous error codes directly.

Variants§

§

Sys(UErrorCode)

The error originating in the underlying sys library.

At the moment it is possible to produce an Error which has a zero error code (i.e. no error), because it makes it unnecessary for users to deal with error codes directly. It does make for a bit weird API, so we may turn it around a bit. Ideally, it should not be possible to have an Error that isn’t really an error.

§

Wrapper(Error)

Errors originating from the wrapper code. For example when pre-converting input into UTF8 for input that happens to be malformed.

Implementations§

Source§

impl Error

Source

pub const OK_CODE: UErrorCode = sys::UErrorCode::U_ZERO_ERROR

The error code denoting no error has happened.

Source

pub fn is_ok(code: UErrorCode) -> bool

Returns true if this error code corresponds to no error.

Source

pub fn ok_or_warning(status: UErrorCode) -> Result<(), Self>

Creates a new error from the supplied status. Ok is returned if the error code does not correspond to an error code (as opposed to OK or a warning code).

Source

pub fn ok_preflight(status: UErrorCode) -> Result<(), Self>

Creates a new error from the supplied status. Ok is returned if the error code does not constitute an error in preflight mode.

This error check explicitly ignores the buffer overflow error when reporting whether it contains an error condition.

Preflight calls to ICU libraries do a read-only scan of the input to determine the buffer sizes required on the output in case of conversion calls such as ucal_strFromUTF8. The way this call is made is to offer a zero-capacity buffer (which could be pointed to by a NULL pointer), and then call the respective function. The function will compute the buffer size, but will also return a bogus buffer overflow error.

Source

pub fn is_code(&self, code: UErrorCode) -> bool

Returns true if this error has the supplied code.

Source

pub fn is_err(&self) -> bool

Returns true if the error is an error, not a warning.

The ICU4C library has error codes for errors and warnings.

Source

pub fn is_preflight_err(&self) -> bool

Return true if there was an error in a preflight call.

This error check explicitly ignores the buffer overflow error when reporting whether it contains an error condition.

Preflight calls to ICU libraries do a read-only scan of the input to determine the buffer sizes required on the output in case of conversion calls such as ucal_strFromUTF8. The way this call is made is to offer a zero-capacity buffer (which could be pointed to by a NULL pointer), and then call the respective function. The function will compute the buffer size, but will also return a bogus buffer overflow error.

Source

pub fn is_warn(&self) -> bool

Returns true if the error is, in fact, a warning (nonfatal).

Source

pub fn wrapper(source: impl Into<Error>) -> Self

Trait Implementations§

Source§

impl Debug for Error

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

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

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

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

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

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

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. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<FromUtf8Error> for Error

Source§

fn from(e: FromUtf8Error) -> Self

Converts to this type from the input type.
Source§

impl From<NulError> for Error

Source§

fn from(e: NulError) -> Self

Converts to this type from the input type.
Source§

impl From<Utf8Error> for Error

Source§

fn from(e: Utf8Error) -> Self

Converts to this type from the input type.
Source§

impl Into<Error> for Error

Source§

fn into(self) -> Error

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.