[][src]Struct rust_icu_ustring::UChar

pub struct UChar { /* fields omitted */ }

The implementation of the ICU UChar*.

While the original type is defined in umachine.h, most useful functions for manipulating UChar* are in fact here.

The first thing you probably want to do is to start from a UTF-8 rust string, produce a UChar. This is necessarily done with a conversion. See the TryFrom implementations in this crate for that.

Implements UChar* from ICU.

Methods

impl UChar[src]

pub fn new_with_capacity(capacity: usize) -> UChar[src]

Allocates a new UChar with given capacity.

Capacity and size must always be the same with UChar when used for interacting with low-level code.

pub fn make_z(&mut self)[src]

Converts into a zeroed-out string.

This is a very weird ICU API thing, where there apparently exists a zero-terminated UChar*.

pub fn as_c_ptr(&self) -> *const UChar[src]

Returns the constant pointer to the underlying C representation. Intended for use in low-level code.

pub fn len(&self) -> usize[src]

Returns the length of the string, in code points.

pub fn as_mut_c_ptr(&mut self) -> *mut UChar[src]

Returns the underlying representation as a mutable C representation. Caller MUST ensure that the representation won't be reallocated as result of adding anything to it, and that it is correctly sized, or bad things will happen.

pub fn resize(&mut self, new_size: usize)[src]

Resizes this string to match new_size.

If the string is made longer, the new space is filled with zeroes.

Trait Implementations

impl Debug for UChar[src]

impl<'_> TryFrom<&'_ UChar> for String[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(u: &UChar) -> Result<String, Self::Error>[src]

Tries to produce a UTF-8 encoded rust string from a UChar.

This conversion ignores warnings and only reports actual ICU errors when they happen.

Implements u_strToUTF8.

impl<'_> TryFrom<&'_ str> for UChar[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(rust_string: &str) -> Result<Self, Self::Error>[src]

Tries to produce a string from the UTF-8 encoded thing.

This conversion ignores warnings (e.g. warnings about unterminated buffers), since for rust they are not relevant.

Implements u_strFromUTF8.

Auto Trait Implementations

impl RefUnwindSafe for UChar

impl Send for UChar

impl Sync for UChar

impl Unpin for UChar

impl UnwindSafe for UChar

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