Skip to main content

FigletBuilder

Struct FigletBuilder 

Source
pub struct FigletBuilder { /* private fields */ }
Expand description

Fluent builder for Figlet renderers.

Construct via FigletBuilder::new and chain configuration methods (#[must_use]); terminate with FigletBuilder::build to obtain a reusable Figlet, or use FigletBuilder::render as a one-shot.

use rusty_figlet::{FigletBuilder, Font};

let figlet = FigletBuilder::new()
    .font(Font::Standard)
    .width(80)
    .build()
    .expect("build");
let _banner = figlet.render("X").expect("render");

Implementations§

Source§

impl FigletBuilder

Source

pub fn new() -> Self

Construct a builder with all defaults:

  • font: Font::Standard (resolves to standard.flf)
  • width: 80 columns
  • layout: font-default
  • justify: font-default
Source

pub fn font(self, font: Font) -> Self

Select a font.

When font is one of the 12 bundled variants, build resolves the embedded .flf bytes via include_bytes!. When font is Font::External, the supplied path is resolved at build() time. Default: Font::Standard.

Source

pub fn font_bytes(self, bytes: &[u8]) -> Self

Supply raw .flf bytes directly (no filesystem access; FR-052 + FR-056). Overrides any prior font call.

Source

pub fn font_dirs(self, dirs: Vec<PathBuf>) -> Self

Add an extra directory to search for Font::External resolutions (CLI -d <dir> counterpart per FR-010). Repeatable; directories are searched in the order added. Has no effect on bundled or font_bytes sources.

Source

pub fn width(self, cols: u32) -> Self

Set the output width budget in columns. Default: 80.

Source

pub fn kerning(self) -> Self

Force horizontal kerning (-k CLI counterpart). Overrides the font’s default layout. Last layout-override wins.

Source

pub fn full_width(self) -> Self

Force full-width layout (-W CLI counterpart). Overrides the font’s default layout. Last layout-override wins.

Source

pub fn smush(self) -> Self

Force smushing per the font’s smush bits (-S CLI counterpart). Overrides the font’s default layout. Last layout-override wins.

Source

pub fn layout(self, flags: LayoutFlags) -> Self

Apply a full sequence of layout-class flag occurrences with last-wins semantics (FR-023). When non-empty, this sequence supersedes any per-method kerning / full_width / smush override.

use rusty_figlet::{FigletBuilder, LayoutFlag, LayoutFlags};

let flags = LayoutFlags {
    flags: vec![LayoutFlag::FullWidth, LayoutFlag::Kerning],
};
let _ = FigletBuilder::new().layout(flags);
Source

pub fn justify(self, j: Justify) -> Self

Set the justification mode. Default: font’s print-direction default.

Source

pub fn build(self) -> Result<Figlet, FigletError>

Resolve the font, parse the .flf, and build a reusable Figlet renderer.

Source

pub fn render(self, text: &str) -> Result<Banner, FigletError>

Terminal convenience equivalent to self.build()?.render(text).

Trait Implementations§

Source§

impl Clone for FigletBuilder

Source§

fn clone(&self) -> FigletBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FigletBuilder

Source§

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

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

impl Default for FigletBuilder

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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