Skip to main content

serverless_fn/
lib.rs

1//! Serverless Function Library
2//!
3//! A Rust library that simplifies the development and invocation of serverless functions.
4//! Allows calling serverless functions as if they were ordinary functions,
5//! with deployment strategy determined by crate feature flags.
6//!
7//! # Features
8//!
9//! - **Simplified Interface**: Same syntax as regular function calls
10//! - **Smart Deployment**: Automatic deployment strategy based on feature flags
11//! - **Local Debugging**: Test without actual deployment
12//! - **Type Safety**: Compile-time type checking for parameters and return values
13//!
14//! # Example
15//!
16//! ```rust,no_run
17//! use serverless_fn::{serverless, ServerlessError};
18//! use serde::{Serialize, Deserialize};
19//!
20//! #[derive(Serialize, Deserialize, Debug)]
21//! pub struct Post {
22//!     pub id: u64,
23//!     pub title: String,
24//!     pub content: String,
25//! }
26//!
27//! #[serverless]
28//! pub async fn read_posts(how_many: usize, query: String) -> Result<Vec<Post>, ServerlessError> {
29//!     Ok((0..how_many)
30//!         .map(|i| Post {
31//!             id: i as u64,
32//!             title: format!("Post {}", i),
33//!             content: format!("Content of post {}", i),
34//!         })
35//!         .collect())
36//! }
37//! ```
38//!
39//! # Feature Flags
40//!
41//! - `remote_call`: Enable remote invocation mode (default)
42//! - `local_call`: Enable local function call mode
43//! - `json_serialization`: Use JSON serialization (default)
44//! - `postcard_serialization`: Use Postcard serialization
45//! - `mock_server`: Enable mock server for testing
46//! - `telemetry`: Enable telemetry and monitoring
47
48#![warn(missing_docs)]
49#![warn(rustdoc::missing_crate_level_docs)]
50
51pub mod client;
52pub mod config;
53pub mod error;
54pub mod serializer;
55pub mod server;
56pub mod telemetry;
57pub mod transport;
58
59// Re-export macros
60pub use serverless_fn_macro::serverless;
61
62// Re-export commonly used types
63pub use error::ServerlessError;
64pub use server::FunctionServer;
65
66// Re-export server components
67pub use server::{FunctionHandler, FunctionRegistry, ServerConfig};
68
69pub use transport::http::HttpTransport;
70
71// Re-export config types
72pub use config::{Config, ConfigBuilder, DeployStrategy};