Converter

Struct Converter 

Source
pub struct Converter<'pivot> { /* private fields */ }
Expand description

Converts between two encodings using ICU.

Implementations§

Source§

impl<'pivot> Converter<'pivot>

Source

pub fn new( pivot_buffer: &'pivot mut [MaybeUninit<u16>], source_encoding: &str, target_encoding: &str, ) -> Result<Self>

Constructs a new Converter instance.

§Parameters
  • pivot_buffer: A buffer used to cache partial conversions. Don’t make it too small.
  • source_encoding: The source encoding name (e.g., “UTF-8”).
  • target_encoding: The target encoding name (e.g., “UTF-16”).
Source

pub fn convert( &mut self, input: &[u8], output: &mut [MaybeUninit<u8>], ) -> Result<(usize, usize)>

Performs one step of the encoding conversion.

§Parameters
  • input: The input buffer to convert from. It should be in the source_encoding that was previously specified.
  • output: The output buffer to convert to. It should be in the target_encoding that was previously specified.
§Returns

A tuple containing:

  1. The number of bytes read from the input buffer.
  2. The number of bytes written to the output buffer.

Trait Implementations§

Source§

impl Drop for Converter<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'pivot> Freeze for Converter<'pivot>

§

impl<'pivot> RefUnwindSafe for Converter<'pivot>

§

impl<'pivot> !Send for Converter<'pivot>

§

impl<'pivot> !Sync for Converter<'pivot>

§

impl<'pivot> Unpin for Converter<'pivot>

§

impl<'pivot> !UnwindSafe for Converter<'pivot>

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