pub struct CatalogBuilder<'a> { /* private fields */ }Expand description
A builder for constructing a Catalog.
CatalogBuilder allows control over the process of constructing a
Catalog. If the default options are acceptable, Catalog::new bypasses
the need for CatalogBuilder.
Implementations§
Source§impl<'a> CatalogBuilder<'a>
impl<'a> CatalogBuilder<'a>
Sourcepub fn build(self) -> Catalog
pub fn build(self) -> Catalog
Builds a Catalog and chooses a default paper size by reading the by
reading paperspecs and papersize files and examining the
environment and (on GNU/Linux) locale.
If no system or user paperspecs files exist, or if they exist but they
contain no valid paper specifications, then this method uses the
standard paper sizes in STANDARD_PAPERSPECS. This is usually a
reasonable fallback.
Sourcepub fn build_from_fallback(self) -> Catalog
pub fn build_from_fallback(self) -> Catalog
Builds a Catalog from STANDARD_PAPERSPECS and chooses a default
paper size by reading the by reading papersize files and examining the
environment and (on GNU/Linux) locale.
This is a reasonable choice if it is unlikely for paperspecs to be
installed but it is still desirable to detect a default paper size.
Sourcepub fn build_without_fallback(self) -> Option<Catalog>
pub fn build_without_fallback(self) -> Option<Catalog>
Tries to build a Catalog and chooses a default paper size by reading
the by reading paperspecs and papersize files and examining the
environment and (on GNU/Linux) locale.
If no system or user paperspecs files exist, or if they exist but they
contain no valid paper specifications, this method fails and returns
None.
Sourcepub fn with_papersize_value(self, papersize: Option<&'a str>) -> Self
pub fn with_papersize_value(self, papersize: Option<&'a str>) -> Self
Sets papersize to be used for the value of the PAPERSIZE environment
variable, instead of obtaining it from the process environment. None
means that the environment variable is assumed to be empty or absent.
Sourcepub fn without_locale(self) -> Self
pub fn without_locale(self) -> Self
On GNU/Linux, by default, CatalogBuilder will consider the paper size
setting in the glibc locale LC_PAPER. This method disables this
feature.
This setting has no effect on other operating systems, which do not support paper size as part of their locales.
Sourcepub fn with_user_config_dir(self, user_config_dir: Option<&'a Path>) -> Self
pub fn with_user_config_dir(self, user_config_dir: Option<&'a Path>) -> Self
Overrides the name of the user-specific configuration directory.
This directory is searched for the user-specified paperspecs and
papersize files. It defaults to $XDG_CONFIG_HOME, which is usually
$HOME/.config.
Passing None will disable reading paperspec or papersize from the
user configuration directory.
Sourcepub fn with_system_config_dir(self, system_config_dir: Option<&'a Path>) -> Self
pub fn with_system_config_dir(self, system_config_dir: Option<&'a Path>) -> Self
Overrides the name of the system configuration directory.
This directory is searched for the system paperspecs and papersize
files. It defaults to /etc.
Passing None will disable reading paperspec or papersize from the
system configuration directory.
Sourcepub fn with_error_callback(
self,
error_cb: Box<dyn FnMut(CatalogBuildError) + 'a>,
) -> Self
pub fn with_error_callback( self, error_cb: Box<dyn FnMut(CatalogBuildError) + 'a>, ) -> Self
Sets an error reporting callback.
By default, CatalogBuilder ignores errors while building the catalog.
The error_cb callback allows the caller to receive information about
these errors.
It is not considered an error if paperspecs or papersize files do
not exist.