1#![doc = include_str!("../README.md")]
2#![doc(
3 html_logo_url = "https://raw.githubusercontent.com/shuttle-hq/shuttle/main/assets/logo-square-transparent.png",
4 html_favicon_url = "https://raw.githubusercontent.com/shuttle-hq/shuttle/main/assets/favicon.ico"
5)]
6
7mod plugins;
9mod rt;
11mod start;
12
13#[cfg(feature = "setup-otel-exporter")]
14mod telemetry;
15
16pub use async_trait::async_trait;
19pub use plugins::{Metadata, Secrets};
20pub use shuttle_codegen::main;
21pub use shuttle_service::{
22 CustomError, DbInput, DeploymentMetadata, Environment, Error, IntoResource, ResourceFactory,
23 ResourceInputBuilder, SecretStore, Service,
24};
25pub use tokio;
26
27const VERSION_STRING: &str = concat!(env!("CARGO_PKG_NAME"), " ", env!("CARGO_PKG_VERSION"));
28
29#[doc(hidden)]
31pub mod __internals {
32 pub use crate::start::start;
34
35 pub use anyhow::Context;
37 pub use serde_json;
38 pub use strfmt::strfmt;
39
40 use super::*;
41 use std::future::Future;
42
43 #[async_trait]
44 pub trait Loader {
45 async fn load(self, factory: ResourceFactory) -> Result<Vec<Vec<u8>>, Error>;
46 }
47
48 #[async_trait]
49 impl<F, O> Loader for F
50 where
51 F: FnOnce(ResourceFactory) -> O + Send,
52 O: Future<Output = Result<Vec<Vec<u8>>, Error>> + Send,
53 {
54 async fn load(self, factory: ResourceFactory) -> Result<Vec<Vec<u8>>, Error> {
55 self(factory).await
56 }
57 }
58
59 #[async_trait]
60 pub trait Runner {
61 type Service: Service;
62
63 async fn run(self, resources: Vec<Vec<u8>>) -> Result<Self::Service, Error>;
64 }
65
66 #[async_trait]
67 impl<F, O, S> Runner for F
68 where
69 F: FnOnce(Vec<Vec<u8>>) -> O + Send,
70 O: Future<Output = Result<S, Error>> + Send,
71 S: Service,
72 {
73 type Service = S;
74
75 async fn run(self, resources: Vec<Vec<u8>>) -> Result<Self::Service, Error> {
76 self(resources).await
77 }
78 }
79}