pub struct App { /* private fields */ }Expand description
A small local application context with effective validated manifests.
App::new creates a standalone, local-only deployment: no listener,
cluster, gateway, peer RPC, AI, storage path or external service is started
implicitly. The default storage and transport provider identifiers exist in
the deployment contract only; an application-owned deployment selects their
implementation when it later opts into explicit manifest execution.
Implementations§
Source§impl App
impl App
Sourcepub fn new(name: &str) -> AppResult<Self>
pub fn new(name: &str) -> AppResult<Self>
Creates a local application with validated V1 standalone defaults.
The resulting manifests are equivalent to the minimal canonical
contracts, not a second SDK-specific configuration format.
Examples found in repository?
More examples
18fn main() -> AppResult<()> {
19 // The defaults are regular V1 contracts, not a second SDK format.
20 let defaults = App::new("explicit-manifests")?;
21
22 let application = defaults.effective_application_manifest().clone();
23 let deployment = defaults.effective_deployment_manifest().clone();
24
25 // Explicit inputs replace the defaults after their normal validation.
26 App::new("explicit-manifests")?
27 .application_manifest(application)?
28 .deployment_manifest(deployment)?
29 .run(|app| {
30 let log = app.logger().component("manifest");
31
32 log.info("Explicit V1 manifests are now in effect");
33
34 Ok(())
35 })
36}16fn main() -> AppResult<()> {
17 let logger = LoggerConfig {
18 output: LogOutputMode::CrashOnly,
19 file: Some(FileSinkConfig {
20 path: std::env::temp_dir().join("example-application-crash.jsonl"),
21 max_bytes: LOG_SIZE_2_MIB,
22 sync_each_write: true,
23 retention: 1,
24 archive: None,
25 }),
26 crash_events: 128,
27 crash_bytes: 512 * 1024,
28 ..LoggerConfig::default()
29 };
30
31 App::new("configured-logging")?.logging(logger)?.run(|app| {
32 let log = app.logger().component("startup");
33
34 log.info("application initialized");
35
36 // A real application calls this from its crash boundary.
37 let _written = app.dump_crash_log()?;
38
39 Ok(())
40 })
41}Sourcepub fn application_manifest(
self,
manifest: ApplicationManifestV1,
) -> AppResult<Self>
pub fn application_manifest( self, manifest: ApplicationManifestV1, ) -> AppResult<Self>
Replaces the application manifest after normal contract validation.
Explicit configuration always wins over SDK defaults. Invalid input is
returned unchanged as an error and is never silently replaced.
Examples found in repository?
18fn main() -> AppResult<()> {
19 // The defaults are regular V1 contracts, not a second SDK format.
20 let defaults = App::new("explicit-manifests")?;
21
22 let application = defaults.effective_application_manifest().clone();
23 let deployment = defaults.effective_deployment_manifest().clone();
24
25 // Explicit inputs replace the defaults after their normal validation.
26 App::new("explicit-manifests")?
27 .application_manifest(application)?
28 .deployment_manifest(deployment)?
29 .run(|app| {
30 let log = app.logger().component("manifest");
31
32 log.info("Explicit V1 manifests are now in effect");
33
34 Ok(())
35 })
36}Sourcepub fn deployment_manifest(
self,
manifest: DeploymentManifestV1,
) -> AppResult<Self>
pub fn deployment_manifest( self, manifest: DeploymentManifestV1, ) -> AppResult<Self>
Replaces the deployment manifest after normal contract validation.
An explicit deployment never inherits cluster, provider or networking
values from the SDK default; it entirely owns installation policy.
Examples found in repository?
18fn main() -> AppResult<()> {
19 // The defaults are regular V1 contracts, not a second SDK format.
20 let defaults = App::new("explicit-manifests")?;
21
22 let application = defaults.effective_application_manifest().clone();
23 let deployment = defaults.effective_deployment_manifest().clone();
24
25 // Explicit inputs replace the defaults after their normal validation.
26 App::new("explicit-manifests")?
27 .application_manifest(application)?
28 .deployment_manifest(deployment)?
29 .run(|app| {
30 let log = app.logger().component("manifest");
31
32 log.info("Explicit V1 manifests are now in effect");
33
34 Ok(())
35 })
36}Sourcepub fn effective_application_manifest(&self) -> &ApplicationManifestV1
pub fn effective_application_manifest(&self) -> &ApplicationManifestV1
Returns the validated application-owned manifest currently in effect.
Examples found in repository?
18fn main() -> AppResult<()> {
19 // The defaults are regular V1 contracts, not a second SDK format.
20 let defaults = App::new("explicit-manifests")?;
21
22 let application = defaults.effective_application_manifest().clone();
23 let deployment = defaults.effective_deployment_manifest().clone();
24
25 // Explicit inputs replace the defaults after their normal validation.
26 App::new("explicit-manifests")?
27 .application_manifest(application)?
28 .deployment_manifest(deployment)?
29 .run(|app| {
30 let log = app.logger().component("manifest");
31
32 log.info("Explicit V1 manifests are now in effect");
33
34 Ok(())
35 })
36}Sourcepub fn effective_deployment_manifest(&self) -> &DeploymentManifestV1
pub fn effective_deployment_manifest(&self) -> &DeploymentManifestV1
Returns the validated installation-owned manifest currently in effect.
Examples found in repository?
18fn main() -> AppResult<()> {
19 // The defaults are regular V1 contracts, not a second SDK format.
20 let defaults = App::new("explicit-manifests")?;
21
22 let application = defaults.effective_application_manifest().clone();
23 let deployment = defaults.effective_deployment_manifest().clone();
24
25 // Explicit inputs replace the defaults after their normal validation.
26 App::new("explicit-manifests")?
27 .application_manifest(application)?
28 .deployment_manifest(deployment)?
29 .run(|app| {
30 let log = app.logger().component("manifest");
31
32 log.info("Explicit V1 manifests are now in effect");
33
34 Ok(())
35 })
36}Sourcepub fn logging(self, config: LoggerConfig) -> AppResult<Self>
pub fn logging(self, config: LoggerConfig) -> AppResult<Self>
Selects explicit bounded logging destinations for this application.
File, terminal, combined, disabled and crash-only modes are provided by
crate::logging::LoggerConfig. Invalid limits fail during setup.
Examples found in repository?
16fn main() -> AppResult<()> {
17 let logger = LoggerConfig {
18 output: LogOutputMode::CrashOnly,
19 file: Some(FileSinkConfig {
20 path: std::env::temp_dir().join("example-application-crash.jsonl"),
21 max_bytes: LOG_SIZE_2_MIB,
22 sync_each_write: true,
23 retention: 1,
24 archive: None,
25 }),
26 crash_events: 128,
27 crash_bytes: 512 * 1024,
28 ..LoggerConfig::default()
29 };
30
31 App::new("configured-logging")?.logging(logger)?.run(|app| {
32 let log = app.logger().component("startup");
33
34 log.info("application initialized");
35
36 // A real application calls this from its crash boundary.
37 let _written = app.dump_crash_log()?;
38
39 Ok(())
40 })
41}Sourcepub fn log(&self, message: &str)
pub fn log(&self, message: &str)
Emits one informational message through AppCore’s redacting logger.
Logging is an observability side effect; setup and business failures must still be returned by the caller’s callback.
Sourcepub fn logger(&self) -> LogBuilder<'_>
pub fn logger(&self) -> LogBuilder<'_>
Returns a fluent logger scoped to this application.
Use app.logger().info("started") for an explicit severity, or add
.component("sync").verbosity(7) before the final severity method.
Examples found in repository?
More examples
18fn main() -> AppResult<()> {
19 // The defaults are regular V1 contracts, not a second SDK format.
20 let defaults = App::new("explicit-manifests")?;
21
22 let application = defaults.effective_application_manifest().clone();
23 let deployment = defaults.effective_deployment_manifest().clone();
24
25 // Explicit inputs replace the defaults after their normal validation.
26 App::new("explicit-manifests")?
27 .application_manifest(application)?
28 .deployment_manifest(deployment)?
29 .run(|app| {
30 let log = app.logger().component("manifest");
31
32 log.info("Explicit V1 manifests are now in effect");
33
34 Ok(())
35 })
36}16fn main() -> AppResult<()> {
17 let logger = LoggerConfig {
18 output: LogOutputMode::CrashOnly,
19 file: Some(FileSinkConfig {
20 path: std::env::temp_dir().join("example-application-crash.jsonl"),
21 max_bytes: LOG_SIZE_2_MIB,
22 sync_each_write: true,
23 retention: 1,
24 archive: None,
25 }),
26 crash_events: 128,
27 crash_bytes: 512 * 1024,
28 ..LoggerConfig::default()
29 };
30
31 App::new("configured-logging")?.logging(logger)?.run(|app| {
32 let log = app.logger().component("startup");
33
34 log.info("application initialized");
35
36 // A real application calls this from its crash boundary.
37 let _written = app.dump_crash_log()?;
38
39 Ok(())
40 })
41}Sourcepub fn prepare<A>(
&self,
application: &A,
node_id: NodeId,
) -> AppResult<PreparedApplication>where
A: Application + ?Sized,
pub fn prepare<A>(
&self,
application: &A,
node_id: NodeId,
) -> AppResult<PreparedApplication>where
A: Application + ?Sized,
Collects an Application’s behavior into executable Core registries.
Preparation performs no I/O and starts no service. It validates and
freezes registrations so an explicit deployment can inspect or execute
them without importing RuntimeBuilder.
§Errors
Returns the exact controlled Runtime error produced by a registration hook, an invalid node identity or inconsistent decision registration.
§Examples
use appcore_sdk::application::NodeId;
use appcore_sdk::{App, Application, AppResult};
struct Business;
impl Application for Business {}
let app = App::new("prepared-example")?;
let prepared = app.prepare(&Business, NodeId::new("local-node")?)?;
assert!(prepared.runtime().commands().is_empty());Sourcepub fn dump_crash_log(&self) -> AppResult<usize>
pub fn dump_crash_log(&self) -> AppResult<usize>
Persists the bounded crash ring when crash-only logging is configured.
Other output modes return zero without creating a file.
Examples found in repository?
16fn main() -> AppResult<()> {
17 let logger = LoggerConfig {
18 output: LogOutputMode::CrashOnly,
19 file: Some(FileSinkConfig {
20 path: std::env::temp_dir().join("example-application-crash.jsonl"),
21 max_bytes: LOG_SIZE_2_MIB,
22 sync_each_write: true,
23 retention: 1,
24 archive: None,
25 }),
26 crash_events: 128,
27 crash_bytes: 512 * 1024,
28 ..LoggerConfig::default()
29 };
30
31 App::new("configured-logging")?.logging(logger)?.run(|app| {
32 let log = app.logger().component("startup");
33
34 log.info("application initialized");
35
36 // A real application calls this from its crash boundary.
37 let _written = app.dump_crash_log()?;
38
39 Ok(())
40 })
41}Sourcepub fn run<F>(self, configure: F) -> AppResult<()>
pub fn run<F>(self, configure: F) -> AppResult<()>
Runs a local callback using the effective validated manifests.
This deliberately does not create a hidden host. When an application needs provider composition or long-running services, it owns an explicit deployment process; the same manifest values can then be serialized.
Examples found in repository?
18fn main() -> AppResult<()> {
19 // The defaults are regular V1 contracts, not a second SDK format.
20 let defaults = App::new("explicit-manifests")?;
21
22 let application = defaults.effective_application_manifest().clone();
23 let deployment = defaults.effective_deployment_manifest().clone();
24
25 // Explicit inputs replace the defaults after their normal validation.
26 App::new("explicit-manifests")?
27 .application_manifest(application)?
28 .deployment_manifest(deployment)?
29 .run(|app| {
30 let log = app.logger().component("manifest");
31
32 log.info("Explicit V1 manifests are now in effect");
33
34 Ok(())
35 })
36}More examples
16fn main() -> AppResult<()> {
17 let logger = LoggerConfig {
18 output: LogOutputMode::CrashOnly,
19 file: Some(FileSinkConfig {
20 path: std::env::temp_dir().join("example-application-crash.jsonl"),
21 max_bytes: LOG_SIZE_2_MIB,
22 sync_each_write: true,
23 retention: 1,
24 archive: None,
25 }),
26 crash_events: 128,
27 crash_bytes: 512 * 1024,
28 ..LoggerConfig::default()
29 };
30
31 App::new("configured-logging")?.logging(logger)?.run(|app| {
32 let log = app.logger().component("startup");
33
34 log.info("application initialized");
35
36 // A real application calls this from its crash boundary.
37 let _written = app.dump_crash_log()?;
38
39 Ok(())
40 })
41}