Skip to main content

saddle/
lib.rs

1//! The only Saddle crate that business applications directly depend on.
2//!
3//! Pool construction and Service registry assembly remain framework-owned:
4//!
5//! ```compile_fail
6//! let _ = saddle::db::Database::connect;
7//! ```
8//!
9//! ```compile_fail
10//! let _ = saddle::service::ServiceRegistryBuilder::new();
11//! ```
12//!
13//! The old static/three-argument launcher is not a public surface:
14//!
15//! ```compile_fail
16//! let _ = saddle::Saddle::run;
17//! ```
18
19mod application;
20#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
21mod http1;
22mod startup_candidate;
23
24pub use application::ProductionLauncher;
25pub use application::SaddleConfig;
26pub use application::{
27    ApprovedBundleNonceReservation, ApprovedExternalBundle,
28    ApprovedExternalBundleApplicabilityFailure, ApprovedExternalBundleSeal,
29    ApprovedExternalBundleVerification, ListenerAuthorityProvider, ListenerAuthoritySeal,
30    VerifiedListenerAuthority,
31};
32#[doc(hidden)]
33pub use application::{
34    GeneratedApplicationBindingError, GeneratedApplicationConsumer, GeneratedApplicationOwner,
35    GeneratedApplicationParts, GeneratedApplicationSeal, GeneratedBoundApplicationParts,
36    GeneratedProductionBootstrap,
37};
38/// Framework/Skill assembly handshake. This is not a business API.
39#[doc(hidden)]
40#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
41pub mod internal {
42    pub use crate::http1::bootstrap::{
43        ApprovedGeneratedHttp1Facts, GeneratedApplicationBootstrap, GeneratedBootstrapError,
44        GeneratedBootstrapToken, GeneratedCompiledAdapter, GeneratedContextFactory,
45        GeneratedHttp1StaticFacts, GeneratedRoute, generated_bootstrap_type_identity,
46        generated_http1_framing_identity,
47    };
48}
49
50pub use saddle_core::{ErrorKind, Result, SaddleError};
51
52/// The complete stable set of business-owned values accepted by generated
53/// Saddle 0.2 handlers.
54pub mod managed {
55    pub use saddle_db::internal::ManagedWriteResult as WriteResult;
56    pub use saddle_service::internal::{
57        ManagedBool as Bool, ManagedPair as Pair, ManagedU64 as U64,
58    };
59
60    /// A fixed optional value delivered to a `query_optional` handler.
61    #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
62    pub struct Optional<T>(Option<T>);
63
64    impl<T> Optional<T> {
65        #[doc(hidden)]
66        pub const fn from_generated(value: Option<T>) -> Self {
67            Self(value)
68        }
69
70        pub fn into_option(self) -> Option<T> {
71            self.0
72        }
73
74        pub const fn as_ref(&self) -> Option<&T> {
75            self.0.as_ref()
76        }
77    }
78}
79
80/// Declares the sole generated Saddle application in a business crate.
81///
82/// The Skill emits a private `__saddle_generated` module beside this
83/// invocation. Only the generated application marker can move that module's
84/// bootstrap owner into the facade.
85#[macro_export]
86macro_rules! application {
87    (
88        schema "saddle-application/1";
89        application $application:ident;
90        $($declaration:tt)*
91    ) => {
92        pub struct $application;
93    };
94    ($($invalid:tt)*) => {
95        compile_error!("skill.schema.unsupported");
96    };
97}