Skip to main content

slim_service/
lib.rs

1// Copyright AGNTCY Contributors (https://github.com/agntcy)
2// SPDX-License-Identifier: Apache-2.0
3
4//! SLIM Service - Main service and public API to interact with SLIM data plane.
5//!
6//! This crate provides the core service functionality for SLIM, including:
7//!
8//! - **Service**: Main service component that manages message processing and connections
9//! - **App**: Application-level API for session management and messaging
10//!
11//! For language bindings (Go, Python, etc.), see the `slim_bindings` crate.
12//!
13//! ## Basic Usage
14//!
15//! ```rust
16//! # tokio_test::block_on(async {
17//! use slim_service::Service;
18//! use slim_config::component::ComponentBuilder;
19//! use slim_auth::shared_secret::SharedSecret;
20//! use slim_datapath::api::ProtoName;
21//!
22//! // Create service instance (handles message processing)
23//! let service = Service::builder().build("svc-0".to_string()).expect("Failed to create service");
24//!
25//! // Create authentication components
26//! let secret = "test-shared-secret-value-0123456789abcdef";
27//! let provider = SharedSecret::new("myapp", secret).unwrap();
28//! let verifier = SharedSecret::new("myapp", secret).unwrap();
29//!
30//! // Create an app for messaging
31//! let app_name = ProtoName::from_strings(["org", "ns", "app"]);
32//! let (app, rx) = service.create_app(&app_name, provider, verifier).expect("Failed to create app");
33//! # })
34//! ```
35
36pub mod errors;
37pub mod service;
38
39#[cfg(feature = "session")]
40pub mod app;
41
42// Third-party crates
43pub use slim_datapath::messages::utils::SlimHeaderFlags;
44
45// Local crate
46pub use errors::ServiceError;
47#[cfg(feature = "session")]
48pub use errors::SubscriptionAckError;
49#[cfg(not(target_arch = "wasm32"))]
50pub use service::ServiceBuilder;
51pub use service::{KIND, Service, ServiceConfiguration};