Struct rust_icu_udata::UDataMemory

source ·
pub struct UDataMemory { /* private fields */ }
Expand description

Implements UDataMemory.

Represents data memory backed by a borrowed memory buffer used for loading ICU data. UDataMemory is very much not thread safe, as it affects the global state of the ICU library. This suggests that the best way to use this data is to load it up in a main thread, or access it through a synchronized wrapper.

Implementations§

source§

impl UDataMemory

source

pub fn open( path: Option<&Path>, a_type: Type, name: Option<&str>, ) -> Result<Self, Error>

Uses the resources from the supplied resource file.

This may end up being more efficient compared to loading from a buffer, as ostensibly the resources would be memory mapped to only the needed parts.

  • The path is the file path at which to find the resource file. Ostensibly specifying None here will load from the “default” ICU_DATA path. I have not been able to confirm this.

  • The a_type is the type of the resource file. It is not clear whether the resource file type is a closed or open set, so we provide for both possibilities.

  • The name is the name of the resource file. It is documented nullable in the ICU documentation. Pass None here to pass nullptr to the underlying C API.

Presumably using UDataMemory::open(Some("/dir/too"), Type::Res, Some("filename") would attempt to load ICU data from /dir/too/filename.res, as well as some other canonical permutations of the above. The full documentation is here, although I could not confirm that the documentation is actually describing what the code does. Also, using None at appropriate places seems to be intended to load data from some “default” sites. I have however observed that the actual behavior diverges from that documentation.

Implements udata_open.

Trait Implementations§

source§

impl Debug for UDataMemory

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for UDataMemory

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl TryFrom<Vec<u8>> for UDataMemory

source§

fn try_from(buf: Vec<u8>) -> Result<Self, Self::Error>

Makes a UDataMemory out of a buffer.

Implements udata_setCommonData.

§

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations§

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

§

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

§

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.