encore-dev 2.0.0-alpha.16

Rust SDK for Encore applications
Documentation
//! The native Rust SDK for [Encore](https://encore.dev).
//!
//! Unlike the Go and TypeScript SDKs (which reach the runtime over a C ABI / napi),
//! this crate links the Rust `encore_sdk_core` directly — Rust calling Rust, no
//! marshalling layer.
//!
//! Infrastructure resources are declared as module-scope `static`s using `const`
//! constructors, mirroring Encore's other SDKs:
//!
//! ```ignore
//! use encore::{pubsub, secrets};
//! use encore::storage::postgres;
//! use encore::pubsub::Topic;
//! use serde::{Serialize, Deserialize};
//!
//! static DB: postgres::Database = postgres::Database::new("hello").migrations("./migrations");
//!
//! #[derive(Serialize, Deserialize)]
//! struct SignupEvent { user_id: String }
//!
//! static SIGNUPS: Topic<SignupEvent> = Topic::new("signups");
//!
//! static API_KEY: secrets::Secret = secrets::Secret::new("ApiKey");
//! ```
//!
//! A service is a directory with an `encore.service.json` (`{ "name": ..., "lang":
//! "rust" }`) and ordinary Rust code. Trait-based services with `#[encore::service]`
//! / `#[endpoint]` and HTTP serving are a later milestone.

// For the tests of `#[encore::test]`, whose output names this crate.
#[cfg(test)]
extern crate self as encore;

mod error;
mod runtime;

pub mod config;
pub mod cron;
pub mod env;
pub mod log;
pub mod metrics;
pub mod objects;
#[doc(hidden)]
pub mod perm;
pub mod pubsub;
pub mod secrets;
pub mod services;
pub mod shutdown;
pub mod storage;
pub mod telemetry;
pub mod testing;

/// The OTel API Encore's tracer and meter providers implement.
pub use encore_sdk_core::telemetry::opentelemetry;

pub use error::{ErrCode, Error};

/// Marks a test, as `#[tokio::test]` does, and tells Encore about it before it
/// runs. See [`testing`].
///
/// ```ignore
/// #[encore::test]
/// async fn creates_a_user() -> Result<(), encore::Error> {
///     // …
/// }
///
/// #[encore::test(flavor = "multi_thread", worker_threads = 2)]
/// async fn handles_concurrent_requests() {
///     // …
/// }
/// ```
pub use encore_macros::test;
pub use env::app_meta;
pub use runtime::{initialize, run_blocking, tokio_handle};