CatalogBuilder

Struct CatalogBuilder 

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

Source

pub fn new() -> Self

Constructs a new CatalogBuilder with default settings.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a> Default for CatalogBuilder<'a>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'a> Freeze for CatalogBuilder<'a>

§

impl<'a> !RefUnwindSafe for CatalogBuilder<'a>

§

impl<'a> !Send for CatalogBuilder<'a>

§

impl<'a> !Sync for CatalogBuilder<'a>

§

impl<'a> Unpin for CatalogBuilder<'a>

§

impl<'a> !UnwindSafe for CatalogBuilder<'a>

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.