Skip to main content

LocaUtils

Struct LocaUtils 

Source
pub struct LocaUtils;
Expand description

Utility functions for loading and saving localization files.

Implementations§

Source§

impl LocaUtils

Source

pub fn load(path: impl AsRef<Path>) -> Result<LocaResource>

Loads a localization resource from a file, detecting format from extension.

Source

pub fn load_with_format( path: impl AsRef<Path>, format: LocaFormat, ) -> Result<LocaResource>

Loads a localization resource from a file with explicit format.

Source

pub fn load_from_reader<R: Read>( reader: R, format: LocaFormat, ) -> Result<LocaResource>

Loads a localization resource from a reader.

Source

pub fn load_from_bytes(data: &[u8], format: LocaFormat) -> Result<LocaResource>

Loads a localization resource from bytes.

Source

pub fn save(resource: &LocaResource, path: impl AsRef<Path>) -> Result<()>

Saves a localization resource to a file, detecting format from extension.

Source

pub fn save_with_format( resource: &LocaResource, path: impl AsRef<Path>, format: LocaFormat, ) -> Result<()>

Saves a localization resource to a file with explicit format.

Source

pub fn save_to_writer<W: Write>( resource: &LocaResource, writer: W, format: LocaFormat, ) -> Result<()>

Saves a localization resource to a writer.

Source

pub fn save_to_bytes( resource: &LocaResource, format: LocaFormat, ) -> Result<Vec<u8>>

Saves a localization resource to bytes.

Source

pub fn convert( input_path: impl AsRef<Path>, output_path: impl AsRef<Path>, ) -> Result<()>

Converts a localization resource between formats.

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

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.