pub struct WriteHandlerChain { /* private fields */ }Expand description
按优先级排序的 PdfWriteHandler 实例有序链。
在每个生命周期阶段,处理程序按优先级升序(最小的最先)调用。 链使用稳定排序,因此优先级相同的处理程序保持注册顺序。
§Examples
use easypdf_core::handler_chain::{WriteHandlerChain, PRIORITY_HIGH, PRIORITY_NORMAL};
use easypdf_core::{PdfWriteHandler, Result};
struct StyleHandler;
impl PdfWriteHandler for StyleHandler {}
struct WatermarkHandler;
impl PdfWriteHandler for WatermarkHandler {}
let mut chain = WriteHandlerChain::new();
chain.register(Box::new(WatermarkHandler), PRIORITY_NORMAL);
chain.register(Box::new(StyleHandler), PRIORITY_HIGH);
// StyleHandler 在 WatermarkHandler 之前运行,因为 HIGH < NORMAL。Implementations§
Source§impl WriteHandlerChain
impl WriteHandlerChain
Sourcepub fn register(&mut self, handler: Box<dyn PdfWriteHandler>, priority: f64)
pub fn register(&mut self, handler: Box<dyn PdfWriteHandler>, priority: f64)
使用给定优先级注册处理程序。
链将在下次生命周期调用前重新排序。
Sourcepub fn before_document(&mut self) -> Result<()>
pub fn before_document(&mut self) -> Result<()>
Sourcepub fn before_page(&mut self, page_number: usize) -> Result<()>
pub fn before_page(&mut self, page_number: usize) -> Result<()>
Sourcepub fn after_page(&mut self, page_number: usize) -> Result<()>
pub fn after_page(&mut self, page_number: usize) -> Result<()>
Sourcepub fn after_document(&mut self) -> Result<()>
pub fn after_document(&mut self) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WriteHandlerChain
impl !Sync for WriteHandlerChain
impl !UnwindSafe for WriteHandlerChain
impl Freeze for WriteHandlerChain
impl Send for WriteHandlerChain
impl Unpin for WriteHandlerChain
impl UnsafeUnpin for WriteHandlerChain
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more