Skip to main content

App

Struct App 

Source
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

Source

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?
examples/03-application/application_contract.rs (line 29)
28fn main() -> AppResult<()> {
29    let app = App::new("reporting")?;
30    let prepared = app.prepare(&ReportingApp, NodeId::new("reporting-local")?)?;
31
32    assert_eq!(prepared.runtime().commands().len(), 1);
33
34    Ok(())
35}
More examples
Hide additional examples
examples/02-manifests/explicit_manifests.rs (line 20)
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}
examples/08-logging/configured_logging.rs (line 31)
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}
Source

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?
examples/02-manifests/explicit_manifests.rs (line 27)
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}
Source

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?
examples/02-manifests/explicit_manifests.rs (line 28)
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}
Source

pub fn effective_application_manifest(&self) -> &ApplicationManifestV1

Returns the validated application-owned manifest currently in effect.

Examples found in repository?
examples/02-manifests/explicit_manifests.rs (line 22)
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}
Source

pub fn effective_deployment_manifest(&self) -> &DeploymentManifestV1

Returns the validated installation-owned manifest currently in effect.

Examples found in repository?
examples/02-manifests/explicit_manifests.rs (line 23)
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}
Source

pub fn id(&self) -> &AppId

Returns the validated application identifier.

Source

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?
examples/08-logging/configured_logging.rs (line 31)
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}
Source

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.

Source

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?
examples/01-basics/hello_world.rs (line 21)
18fn main() -> AppResult<()> {
19    appcore_sdk::run("hello-world", |app| {
20        // `App::logger` carries the application identifier into every event.
21        let log = app.logger();
22
23        log.info("Hello, world!");
24
25        Ok(())
26    })
27}
More examples
Hide additional examples
examples/02-manifests/explicit_manifests.rs (line 30)
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}
examples/08-logging/configured_logging.rs (line 32)
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}
Source

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());
Examples found in repository?
examples/03-application/application_contract.rs (line 30)
28fn main() -> AppResult<()> {
29    let app = App::new("reporting")?;
30    let prepared = app.prepare(&ReportingApp, NodeId::new("reporting-local")?)?;
31
32    assert_eq!(prepared.runtime().commands().len(), 1);
33
34    Ok(())
35}
Source

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?
examples/08-logging/configured_logging.rs (line 37)
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}
Source

pub fn run<F>(self, configure: F) -> AppResult<()>
where F: FnOnce(&App) -> 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?
examples/02-manifests/explicit_manifests.rs (lines 29-35)
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
Hide additional examples
examples/08-logging/configured_logging.rs (lines 31-40)
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}

Trait Implementations§

Source§

impl Debug for App

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for App

§

impl !RefUnwindSafe for App

§

impl !UnwindSafe for App

§

impl Forget for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.