Trait Parser

Source
pub trait Parser {
    // Required methods
    fn from_reader<R: BufRead>(reader: R) -> Result<Self, Error>
       where Self: Sized;
    fn to_writer<W: Write>(&self, writer: W) -> Result<(), Error>;

    // Provided methods
    fn read_from<P: AsRef<Path>>(path: P) -> Result<Self, Error>
       where Self: Sized { ... }
    fn write_to<P: AsRef<Path>>(&self, path: P) -> Result<(), Error> { ... }
    fn from_str(s: &str) -> Result<Self, Error>
       where Self: Sized { ... }
    fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
       where Self: Sized { ... }
}
Expand description

A trait for parsing and writing localization resources from/to one file.

§Example

use langcodec::traits::Parser;
let format = langcodec::formats::strings::Format::read_from("en.strings")?;
format.write_to("en_copy.strings")?;
Ok::<(), Box<dyn std::error::Error>>(())

Required Methods§

Source

fn from_reader<R: BufRead>(reader: R) -> Result<Self, Error>
where Self: Sized,

Parse from any reader.

Source

fn to_writer<W: Write>(&self, writer: W) -> Result<(), Error>

Write to any writer (file, memory, etc.).

Provided Methods§

Source

fn read_from<P: AsRef<Path>>(path: P) -> Result<Self, Error>
where Self: Sized,

Parse from file path.

Source

fn write_to<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Write to file path.

Source

fn from_str(s: &str) -> Result<Self, Error>
where Self: Sized,

Parse from a string.

Source

fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized,

Parse from bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Parser for Vec<CSVRecord>

Source§

fn from_reader<R: BufRead>(reader: R) -> Result<Self, Error>

Parse from any reader.

Source§

fn to_writer<W: Write>(&self, writer: W) -> Result<(), Error>

Write to any writer (file, memory, etc.).

Source§

impl Parser for Vec<Resource>

Source§

fn from_reader<R: BufRead>(reader: R) -> Result<Self, Error>

Parse from any reader.

Source§

fn to_writer<W: Write>(&self, writer: W) -> Result<(), Error>

Write to any writer (file, memory, etc.).

Implementors§

Source§

impl Parser for langcodec::formats::android_strings::Format

Source§

impl Parser for langcodec::formats::strings::Format

Source§

impl Parser for langcodec::formats::xcstrings::Format