[][src]Enum rust_icu_common::Error

pub enum Error {
    Sys(UErrorCode),
    Wrapper(Error),
}

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

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.

Methods

impl Error[src]

pub const OK_CODE: UErrorCode[src]

The error code denoting no error has happened.

pub fn is_ok(code: UErrorCode) -> bool[src]

Returns true if this error code corresponds to no error.

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

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).

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

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 dummy 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.

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

Returns true if this error has the supplied code.

pub fn is_err(&self) -> bool[src]

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

The ICU4C library has error codes for errors and warnings.

pub fn is_preflight_err(&self) -> bool[src]

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 dummy 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.

pub fn is_warn(&self) -> bool[src]

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

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

Trait Implementations

impl Debug for Error[src]

impl Display for Error[src]

impl Error for Error[src]

impl From<FromUtf8Error> for Error[src]

impl From<NulError> for Error[src]

impl From<Utf8Error> for Error[src]

Auto Trait Implementations

impl RefUnwindSafe for Error

impl Send for Error

impl Sync for Error

impl Unpin for Error

impl UnwindSafe for Error

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.