pub struct Converter<'pivot> { /* private fields */ }Expand description
Converts between two encodings using ICU.
Implementations§
Source§impl<'pivot> Converter<'pivot>
impl<'pivot> Converter<'pivot>
Sourcepub fn new(
pivot_buffer: &'pivot mut [MaybeUninit<u16>],
source_encoding: &str,
target_encoding: &str,
) -> Result<Self>
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”).
Sourcepub fn convert(
&mut self,
input: &[u8],
output: &mut [MaybeUninit<u8>],
) -> Result<(usize, usize)>
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 thesource_encodingthat was previously specified.output: The output buffer to convert to. It should be in thetarget_encodingthat was previously specified.
§Returns
A tuple containing:
- The number of bytes read from the input buffer.
- The number of bytes written to the output buffer.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more