pub struct CodecBuilder { /* private fields */ }Implementations§
Source§impl CodecBuilder
impl CodecBuilder
Sourcepub fn add_file<P: AsRef<Path>>(self, path: P) -> Result<Self, Error>
pub fn add_file<P: AsRef<Path>>(self, path: P) -> Result<Self, Error>
Adds a resource file by inferring its format from the file extension.
The language will be automatically inferred from the file path if possible.
For example, en.lproj/Localizable.strings will be detected as English.
§Arguments
path- Path to the resource file
§Returns
Returns self for method chaining, or an Error if the file cannot be read.
Sourcepub fn add_file_with_format<P: AsRef<Path>>(
self,
path: P,
format_type: FormatType,
) -> Result<Self, Error>
pub fn add_file_with_format<P: AsRef<Path>>( self, path: P, format_type: FormatType, ) -> Result<Self, Error>
Adds a resource file with a specific format and optional language override.
This method allows you to specify the format explicitly and optionally override the language that would be inferred from the file path.
§Arguments
path- Path to the resource fileformat_type- The format type to use for parsing
§Returns
Returns self for method chaining, or an Error if the file cannot be read.
Sourcepub fn read_file_by_extension<P: AsRef<Path>>(
self,
path: P,
lang: Option<String>,
) -> Result<Self, Error>
pub fn read_file_by_extension<P: AsRef<Path>>( self, path: P, lang: Option<String>, ) -> Result<Self, Error>
Adds a resource file by inferring its format from the file extension with optional language override.
This method is similar to add_file but allows you to specify a language
that will override any language inferred from the file path.
§Arguments
path- Path to the resource filelang- Optional language code to use (overrides path inference)
§Returns
Returns self for method chaining, or an Error if the file cannot be read.
Sourcepub fn add_resource(self, resource: Resource) -> Self
pub fn add_resource(self, resource: Resource) -> Self
Sourcepub fn add_resources<I>(self, resources: I) -> Selfwhere
I: IntoIterator<Item = Resource>,
pub fn add_resources<I>(self, resources: I) -> Selfwhere
I: IntoIterator<Item = Resource>,
Sourcepub fn build(self) -> Codec
pub fn build(self) -> Codec
Builds the final Codec instance.
This method consumes the builder and returns the constructed Codec.
§Returns
Returns the constructed Codec instance.
Sourcepub fn build_and_validate(self) -> Result<Codec, Error>
pub fn build_and_validate(self) -> Result<Codec, Error>
Builds the final Codec instance and validates it.
This method is similar to build() but performs additional validation
on the resources before returning the Codec.
§Returns
Returns the constructed Codec instance, or an Error if validation fails.