saddle-framework 0.2.0

The single business-facing facade for Saddle applications
Documentation
//! The only Saddle crate that business applications directly depend on.
//!
//! Pool construction and Service registry assembly remain framework-owned:
//!
//! ```compile_fail
//! let _ = saddle::db::Database::connect;
//! ```
//!
//! ```compile_fail
//! let _ = saddle::service::ServiceRegistryBuilder::new();
//! ```
//!
//! The old static/three-argument launcher is not a public surface:
//!
//! ```compile_fail
//! let _ = saddle::Saddle::run;
//! ```

mod application;
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
mod http1;
mod startup_candidate;

pub use application::ProductionLauncher;
pub use application::SaddleConfig;
pub use application::{
    ApprovedBundleNonceReservation, ApprovedExternalBundle,
    ApprovedExternalBundleApplicabilityFailure, ApprovedExternalBundleSeal,
    ApprovedExternalBundleVerification, ListenerAuthorityProvider, ListenerAuthoritySeal,
    VerifiedListenerAuthority,
};
#[doc(hidden)]
pub use application::{
    GeneratedApplicationBindingError, GeneratedApplicationConsumer, GeneratedApplicationOwner,
    GeneratedApplicationParts, GeneratedApplicationSeal, GeneratedBoundApplicationParts,
    GeneratedProductionBootstrap,
};
/// Framework/Skill assembly handshake. This is not a business API.
#[doc(hidden)]
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
pub mod internal {
    pub use crate::http1::bootstrap::{
        ApprovedGeneratedHttp1Facts, GeneratedApplicationBootstrap, GeneratedBootstrapError,
        GeneratedBootstrapToken, GeneratedCompiledAdapter, GeneratedContextFactory,
        GeneratedHttp1StaticFacts, GeneratedRoute, generated_bootstrap_type_identity,
        generated_http1_framing_identity,
    };
}

pub use saddle_core::{ErrorKind, Result, SaddleError};

/// The complete stable set of business-owned values accepted by generated
/// Saddle 0.2 handlers.
pub mod managed {
    pub use saddle_db::internal::ManagedWriteResult as WriteResult;
    pub use saddle_service::internal::{
        ManagedBool as Bool, ManagedPair as Pair, ManagedU64 as U64,
    };

    /// A fixed optional value delivered to a `query_optional` handler.
    #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
    pub struct Optional<T>(Option<T>);

    impl<T> Optional<T> {
        #[doc(hidden)]
        pub const fn from_generated(value: Option<T>) -> Self {
            Self(value)
        }

        pub fn into_option(self) -> Option<T> {
            self.0
        }

        pub const fn as_ref(&self) -> Option<&T> {
            self.0.as_ref()
        }
    }
}

/// Declares the sole generated Saddle application in a business crate.
///
/// The Skill emits a private `__saddle_generated` module beside this
/// invocation. Only the generated application marker can move that module's
/// bootstrap owner into the facade.
#[macro_export]
macro_rules! application {
    (
        schema "saddle-application/1";
        application $application:ident;
        $($declaration:tt)*
    ) => {
        pub struct $application;
    };
    ($($invalid:tt)*) => {
        compile_error!("skill.schema.unsupported");
    };
}