pub struct CharsetEncodeError { /* private fields */ }Expand description
Error reported by a charset encoder.
The error always carries the target charset, error kind, and operation
index associated with the failure. For buffer errors this is the
caller-supplied output index. Errors tied to a raw code point or character
value expose that value through Self::kind and Self::value.
Implementations§
Source§impl CharsetEncodeError
impl CharsetEncodeError
Sourcepub const fn new(
charset: Charset,
kind: CharsetEncodeErrorKind,
index: usize,
) -> Self
pub const fn new( charset: Charset, kind: CharsetEncodeErrorKind, index: usize, ) -> Self
Sourcepub const fn required(self) -> Option<usize>
pub const fn required(self) -> Option<usize>
Returns required output units for this encoding error, if reported.
§Returns
Returns Some(required) for CharsetEncodeErrorKind::BufferTooSmall,
otherwise None.
Sourcepub const fn available(self) -> Option<usize>
pub const fn available(self) -> Option<usize>
Returns available output units for this encoding error, if reported.
§Returns
Returns Some(available) for
CharsetEncodeErrorKind::BufferTooSmall, otherwise None.
Sourcepub const fn output_len(self) -> Option<usize>
pub const fn output_len(self) -> Option<usize>
Returns output length for this encoding error, if reported.
§Returns
Returns Some(output_len) for
CharsetEncodeErrorKind::InvalidOutputIndex, otherwise None.
Sourcepub const fn kind(self) -> CharsetEncodeErrorKind
pub const fn kind(self) -> CharsetEncodeErrorKind
Sourcepub const fn value(self) -> Option<u32>
pub const fn value(self) -> Option<u32>
Returns the raw value associated with this error.
§Returns
Returns Some(value) when the error kind carries a raw code point or
character value, or None for kinds without an associated value.
Sourcepub const fn offset_by(self, base: usize) -> Self
pub const fn offset_by(self, base: usize) -> Self
Offsets this error by a base unit index.
§Parameters
base: The base index to add to the stored index.
§Returns
Returns a copy of this error with its index shifted by base.
If the shifted index cannot be represented, it is saturated to
usize::MAX.
Trait Implementations§
Source§impl Clone for CharsetEncodeError
impl Clone for CharsetEncodeError
Source§fn clone(&self) -> CharsetEncodeError
fn clone(&self) -> CharsetEncodeError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CharsetEncodeError
Source§impl Debug for CharsetEncodeError
impl Debug for CharsetEncodeError
Source§impl Display for CharsetEncodeError
impl Display for CharsetEncodeError
impl Eq for CharsetEncodeError
Source§impl Error for CharsetEncodeError
impl Error for CharsetEncodeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<CharsetEncodeError> for CharsetConvertError
impl From<CharsetEncodeError> for CharsetConvertError
Source§fn from(source: CharsetEncodeError) -> Self
fn from(source: CharsetEncodeError) -> Self
Source§impl PartialEq for CharsetEncodeError
impl PartialEq for CharsetEncodeError
Source§fn eq(&self, other: &CharsetEncodeError) -> bool
fn eq(&self, other: &CharsetEncodeError) -> bool
self and other values to be equal, and is used by ==.