Skip to main content

StampOptionsBuilder

Struct StampOptionsBuilder 

Source
pub struct StampOptionsBuilder(/* private fields */);
Expand description

Builds a StampOptions a setting at a time.

The way to change one field from outside this crate: the type is #[non_exhaustive], so struct-update syntax is a same-crate spelling. Every method consumes and returns the builder; build hands back the options.

use pdfrum::{Color, StampOptions, StampPosition};

let draft = StampOptions::builder()
    .position(StampPosition::Center)
    .angle(45.0)
    .opacity(0.3)
    .font_size(96.0)
    .color(Color::from_rgb8(200, 0, 0))
    .build();

assert_eq!(draft.margin, 36.0);

Implementations§

Source§

impl StampOptionsBuilder

Source

pub fn position(self, position: StampPosition) -> Self

Where the stamp’s box sits — StampOptions::position.

use pdfrum::{StampOptions, StampPosition};

let options = StampOptions::builder().position(StampPosition::TopRight).build();
Source

pub fn margin(self, margin: f64) -> Self

Points between a corner-placed stamp and the crop box — StampOptions::margin.

let options = pdfrum::StampOptions::builder().margin(18.0).build();
assert_eq!(options.margin, 18.0);
Source

pub fn angle(self, angle: f64) -> Self

Degrees counter-clockwise — StampOptions::angle.

let options = pdfrum::StampOptions::builder().angle(45.0).build();
assert_eq!(options.angle, 45.0);
Source

pub fn opacity(self, opacity: f32) -> Self

Constant alpha, 0.0 to 1.0StampOptions::opacity.

let options = pdfrum::StampOptions::builder().opacity(0.3).build();
assert_eq!(options.opacity, 0.3);
Source

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

The face for a text stamp — StampOptions::font.

use pdfrum::{StampOptions, StandardFont};

let options = StampOptions::builder().font(StandardFont::Courier).build();
Source

pub fn font_size(self, size: f32) -> Self

The text size in points — StampOptions::font_size.

let options = pdfrum::StampOptions::builder().font_size(96.0).build();
assert_eq!(options.font_size, 96.0);
Source

pub fn color(self, color: Color) -> Self

The text colour — StampOptions::color.

let options = pdfrum::StampOptions::builder()
    .color(pdfrum::Color::from_rgb8(200, 0, 0))
    .build();
Source

pub fn build(self) -> StampOptions

The options as built.

let options = pdfrum::StampOptions::builder().build();
assert_eq!(options, pdfrum::StampOptions::default());

Trait Implementations§

Source§

impl Clone for StampOptionsBuilder

Source§

fn clone(&self) -> StampOptionsBuilder

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 StampOptionsBuilder

Source§

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

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

impl Default for StampOptionsBuilder

Source§

fn default() -> StampOptionsBuilder

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

impl PartialEq for StampOptionsBuilder

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for StampOptionsBuilder

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.