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
impl UDataMemory
Sourcepub fn open(
path: Option<&Path>,
a_type: Type,
name: Option<&str>,
) -> Result<Self, Error>
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
pathis the file path at which to find the resource file. Ostensibly specifyingNonehere will load from the “default” ICU_DATA path. I have not been able to confirm this. -
The
a_typeis 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
nameis the name of the resource file. It is documented nullable in the ICU documentation. PassNonehere 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.