printwell-pdf 0.1.3

PDF manipulation features (forms, signing) for Printwell
Documentation
//! Cryptographic primitives for PDF signing.
//!
//! **Note:** This feature requires a commercial license.
//! Purchase at: <https://printwell.dev/pricing>

use crate::{Result, SigningError};

/// Trust store for certificate validation.
pub struct TrustStore {
    _private: (),
}

impl TrustStore {
    /// Create a new trust store builder.
    #[must_use]
    pub const fn builder() -> TrustStoreBuilder {
        TrustStoreBuilder::new()
    }

    /// Load the system trust store.
    ///
    /// **Note:** This feature requires a commercial license.
    ///
    /// # Errors
    ///
    /// Always returns an error as this feature requires a commercial license.
    pub fn system() -> Result<Self> {
        Err(SigningError::RequiresLicense.into())
    }
}

/// Builder for `TrustStore`.
#[derive(Default)]
pub struct TrustStoreBuilder {
    _private: (),
}

impl TrustStoreBuilder {
    /// Create a new builder.
    #[must_use]
    pub const fn new() -> Self {
        Self { _private: () }
    }

    /// Add system root certificates.
    #[must_use]
    pub const fn with_system_roots(self) -> Self {
        self
    }

    /// Add certificates from a PEM file.
    ///
    /// # Errors
    ///
    /// Always returns an error as this feature requires a commercial license.
    pub fn with_pem_file(self, _path: impl AsRef<std::path::Path>) -> Result<Self> {
        Err(SigningError::RequiresLicense.into())
    }

    /// Add certificates from PEM data.
    ///
    /// # Errors
    ///
    /// Always returns an error as this feature requires a commercial license.
    pub fn with_pem_data(self, _data: &[u8]) -> Result<Self> {
        Err(SigningError::RequiresLicense.into())
    }

    /// Build the trust store.
    ///
    /// # Errors
    ///
    /// Always returns an error as this feature requires a commercial license.
    pub fn build(self) -> Result<TrustStore> {
        Err(SigningError::RequiresLicense.into())
    }
}