Struct rspolib::FileOptions

source ·
pub struct FileOptions {
    pub path_or_content: String,
    pub wrapwidth: usize,
    pub byte_content: Option<Vec<u8>>,
}
Expand description

File options struct passed when creating a new PO or MO file

Examples

use std::fs;
use rspolib::FileOptions;

// From path
let opts = FileOptions::from("tests-data/all.po");
assert_eq!(opts.path_or_content, "tests-data/all.po");
assert_eq!(opts.wrapwidth, 78);

// From path and wrap width
let opts = FileOptions::from(("tests-data/obsoletes.po", 80));
assert_eq!(opts.path_or_content, "tests-data/obsoletes.po");
assert_eq!(opts.wrapwidth, 80);

// From bytes
let bytes = fs::read("tests-data/obsoletes.po").unwrap();
let opts = FileOptions::from(bytes);

Fields§

§path_or_content: String

Path or content to the file

§wrapwidth: usize

Wrap width for the PO file, used when converted as a string

§byte_content: Option<Vec<u8>>

Content as bytes, used by MO files when the content is passed as bytes

Trait Implementations§

source§

impl Clone for FileOptions

source§

fn clone(&self) -> FileOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FileOptions

source§

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

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

impl Default for FileOptions

source§

fn default() -> FileOptions

Returns the “default value” for a type. Read more
source§

impl<'a> From<&'a str> for FileOptions

source§

fn from(path_or_content: &'a str) -> Self

Converts to this type from the input type.
source§

impl From<&FileOptions> for FileOptions

source§

fn from(options: &Self) -> Self

Converts to this type from the input type.
source§

impl<'a> From<(&'a str, usize)> for FileOptions

source§

fn from(opts: (&'a str, usize)) -> Self

Converts to this type from the input type.
source§

impl From<(Vec<u8, Global>, usize)> for FileOptions

source§

fn from((byte_content, wrapwidth): (Vec<u8>, usize)) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8, Global>> for FileOptions

source§

fn from(byte_content: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl PartialEq<FileOptions> for FileOptions

source§

fn eq(&self, other: &FileOptions) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for FileOptions

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.