Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a utility trait for objects that contain a resource dictionary #37

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,47 @@ pub mod types {
pub use xobject::SMaskInData;
}

/// A number of utility traits that can be used by a consumer.
pub mod traits {
use crate::writers::{FormXObject, Page, Pages, Resources, TilingPattern, Type3Font};

/// A trait for getting the resource dictionary of an object.
pub trait ResourcesExt {
/// Return the resources dictionary of the object.
fn resources(&mut self) -> Resources<'_>;
}

impl ResourcesExt for FormXObject<'_> {
fn resources(&mut self) -> Resources<'_> {
self.resources()
}
}

impl ResourcesExt for TilingPattern<'_> {
fn resources(&mut self) -> Resources<'_> {
self.resources()
}
}

impl ResourcesExt for Type3Font<'_> {
fn resources(&mut self) -> Resources<'_> {
self.resources()
}
}

impl ResourcesExt for Pages<'_> {
fn resources(&mut self) -> Resources<'_> {
self.resources()
}
}

impl ResourcesExt for Page<'_> {
fn resources(&mut self) -> Resources<'_> {
self.resources()
}
}
}

pub use self::chunk::Chunk;
pub use self::content::Content;
pub use self::object::{
Expand Down