Struct RoadsterAppBuilder

Source
pub struct RoadsterAppBuilder<S, Cli: 'static + Args + RunCommand<RoadsterApp<S, Cli>, S> + Send + Sync = Empty>
where S: Clone + Send + Sync + 'static, AppContext: FromRef<S>,
{ /* private fields */ }
Expand description

Builder-style API to build/customize a RoadsterApp.

See https://github.com/roadster-rs/roadster/tree/main/examples/app-builder/src/main.rs for an example of how to use the RoadsterAppBuilder.

The Cli type parameter is only required when the using a custom CLI.

Implementations§

Source§

impl<S, Cli: 'static + Args + RunCommand<RoadsterApp<S, Cli>, S> + Send + Sync> RoadsterAppBuilder<S, Cli>
where S: 'static + Clone + Send + Sync, AppContext: FromRef<S>,

Source

pub fn new() -> Self

Source

pub fn add_async_config_source( self, source: impl AsyncSource + Send + 'static, ) -> Self

Add an async config source (AsyncSource). Useful to load configs/secrets from an external service, e.g., AWS or GCS secrets manager services.

Source

pub fn add_async_config_source_provider( self, source_provider: impl 'static + Send + Sync + Fn(&Environment) -> RoadsterResult<Box<dyn AsyncSource + Send + Sync>>, ) -> Self

Add an async config source (AsyncSource). Useful to load configs/secrets from an external service, e.g., AWS or GCS secrets manager services.

Source

pub fn tracing_initializer( self, tracing_initializer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<()>, ) -> Self

Provide the logic to initialize tracing for the RoadsterApp.

Source

pub fn metadata(self, metadata: AppMetadata) -> Self

Provide the AppMetadata for the RoadsterApp.

Source

pub fn metadata_provider( self, metadata_provider: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<AppMetadata>, ) -> Self

Provide the logic to build the AppMetadata for the RoadsterApp.

Source

pub fn sea_orm_conn_options(self, sea_orm_conn_options: ConnectOptions) -> Self

Provide the ConnectOptions for the RoadsterApp.

Source

pub fn sea_orm_conn_options_provider( self, sea_orm_conn_options_provider: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<ConnectOptions>, ) -> Self

Provide the logic to build the ConnectOptions for the RoadsterApp.

Source

pub fn diesel_pg_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselPgConn, Error>, ) -> Self

Source

pub fn diesel_pg_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselPgConn, Error>>>, ) -> Self

Source

pub fn diesel_mysql_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselMysqlConn, Error>, ) -> Self

Source

pub fn diesel_mysql_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselMysqlConn, Error>>>, ) -> Self

Source

pub fn diesel_sqlite_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselSqliteConn, Error>, ) -> Self

Source

pub fn diesel_sqlite_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselSqliteConn, Error>>>, ) -> Self

Source

pub fn diesel_pg_async_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselPgConnAsync, PoolError>, ) -> Self

Source

pub fn diesel_pg_async_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselPgConnAsync, PoolError>>>, ) -> Self

Source

pub fn diesel_mysql_async_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselMysqlConnAsync, PoolError>, ) -> Self

Source

pub fn diesel_mysql_async_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselMysqlConnAsync, PoolError>>>, ) -> Self

Source

pub fn state_provider( self, builder: impl 'static + Send + Sync + Fn(AppContext) -> RoadsterResult<S>, ) -> Self

Provide the logic to build the custom state for the RoadsterApp.

Source

pub fn sea_orm_migrator( self, migrator: impl 'static + Sync + MigratorTrait, ) -> Self

Add the diesel migrator sea_orm_migration::MigratorTrait to run on app start up (if the database.auto-migrate config field is set to true)

Note: SeaORM migrations expect all of the applied migrations to be available to the provided migrator, so only a single SeaORM migrator is allowed.

Source

pub fn diesel_migrator<C>( self, migrator: impl 'static + Send + Sync + MigrationSource<C::Backend>, ) -> Self
where C: 'static + Connection + Send + MigrationHarness<C::Backend>,

Add the diesel migrator diesel::migration::MigrationSource to run on app start up (if the database.auto-migrate config field is set to true)

Note: Diesel migrations expect all of the applied migrations to be available to the provided migrator, so only a single Diesel migrator is allowed.

Source

pub fn add_migrator(self, migrator: impl Migrator<S> + 'static) -> Self

Add a Migrator to run on app start up (if the database.auto-migrate config field is set to true).

Note: SeaORM and Diesel migrations expect all of the applied migrations to be available to the provided migrator, so multiple SeaORM or Diesel migrators should not be provided via this method.

Source

pub fn add_migrator_provider( self, migrator_provider: impl 'static + Send + Sync + Fn(&S) -> RoadsterResult<Box<dyn Migrator<S>>>, ) -> Self

Add a [MigratorProvider] that provides a Migrator to run on app start up (if the database.auto-migrate config field is set to true).

This is useful compared to Self::add_migrator if the Migrator implementation needs access to the app state for any reason.

Note: SeaORM and Diesel migrations expect all of the applied migrations to be available to the provided migrator, so multiple SeaORM or Diesel migrators should not be provided via this method.

Source

pub fn add_lifecycle_handler( self, lifecycle_handler: impl 'static + AppLifecycleHandler<RoadsterApp<S, Cli>, S>, ) -> Self

Add a AppLifecycleHandler for the RoadsterApp.

This method can be called multiple times to register multiple handlers.

Source

pub fn add_lifecycle_handler_provider( self, lifecycle_handler_provider: impl 'static + Send + Sync + Fn(&mut LifecycleHandlerRegistry<RoadsterApp<S, Cli>, S>, &S) -> RoadsterResult<()>, ) -> Self

Provide the logic to register AppLifecycleHandlers for the RoadsterApp.

This method can be called multiple times to register multiple handlers in separate callbacks.

Source

pub fn add_health_check(self, health_check: impl 'static + HealthCheck) -> Self

Add a HealthCheck for the RoadsterApp.

This method can be called multiple times to register multiple health checks.

Source

pub fn add_health_check_provider( self, health_check_provider: impl 'static + Send + Sync + Fn(&mut HealthCheckRegistry, &S) -> RoadsterResult<()>, ) -> Self

Provide the logic to register HealthChecks for the RoadsterApp.

This method can be called multiple times to register multiple health checks in separate callbacks.

Source

pub fn add_service( self, service: impl 'static + AppService<RoadsterApp<S, Cli>, S>, ) -> Self

Add a AppService for the RoadsterApp.

This method can be called multiple times to register multiple services.

Source

pub fn add_service_provider( self, service_provider: impl 'static + Send + Sync + for<'a> Fn(&'a mut ServiceRegistry<RoadsterApp<S, Cli>, S>, &'a S) -> Pin<Box<dyn Send + Future<Output = RoadsterResult<()>> + 'a>>, ) -> Self

Provide the logic to register AppServices for the RoadsterApp.

This method can be called multiple times to register multiple services in separate callbacks.

Source

pub fn graceful_shutdown_signal_provider( self, graceful_shutdown_signal_provider: impl 'static + Send + Sync + Fn(&S) -> Pin<Box<dyn Send + Future<Output = ()>>>, ) -> Self

Provide a custom signal to listen for in order to shutdown the RoadsterApp.

Source

pub fn build(self) -> RoadsterApp<S, Cli>

Build the RoadsterApp from this RoadsterAppBuilder.

Trait Implementations§

Source§

impl<S, Cli: 'static + Args + RunCommand<RoadsterApp<S, Cli>, S> + Send + Sync> Default for RoadsterAppBuilder<S, Cli>
where S: 'static + Clone + Send + Sync, AppContext: FromRef<S>,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S, Cli> Freeze for RoadsterAppBuilder<S, Cli>

§

impl<S, Cli = Empty> !RefUnwindSafe for RoadsterAppBuilder<S, Cli>

§

impl<S, Cli> Send for RoadsterAppBuilder<S, Cli>

§

impl<S, Cli> Sync for RoadsterAppBuilder<S, Cli>

§

impl<S, Cli> Unpin for RoadsterAppBuilder<S, Cli>

§

impl<S, Cli = Empty> !UnwindSafe for RoadsterAppBuilder<S, Cli>

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> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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> Chain<T> for T

Source§

fn len(&self) -> usize

The number of items that this chain link consists of.
Source§

fn append_to(self, v: &mut Vec<T>)

Append the elements in this link to the chain.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoApi for T

Source§

fn into_api<A>(self) -> UseApi<T, A>

into UseApi
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoResult<T> for T

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, Conn> RunQueryDsl<Conn> for T

Source§

fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnection>::ExecuteFuture<'conn, 'query>
where Conn: AsyncConnection + Send, Self: ExecuteDsl<Conn> + 'query,

Executes the given command, returning the number of rows affected. Read more
Source§

fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
where U: Send, Conn: AsyncConnection, Self: LoadQuery<'query, Conn, U> + 'query,

Executes the given query, returning a Vec with the returned rows. Read more
Source§

fn load_stream<'conn, 'query, U>( self, conn: &'conn mut Conn, ) -> Self::LoadFuture<'conn>
where Conn: AsyncConnection, U: 'conn, Self: LoadQuery<'query, Conn, U> + 'query,

Executes the given query, returning a Stream with the returned rows. Read more
Source§

fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: Self::Stream<'conn>) -> Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>>
where U: Send + 'conn, Conn: AsyncConnection, Self: LoadQuery<'query, Conn, U> + 'query,

Runs the command, and returns the affected row. Read more
Source§

fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
where U: Send, Conn: AsyncConnection, Self: LoadQuery<'query, Conn, U> + 'query,

Runs the command, returning an Vec with the affected rows. Read more
Source§

fn first<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<<Self::Output as LoadQuery<'query, Conn, U>>::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: <Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>) -> Map<StreamFuture<Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>)) -> Result<U, Error>>>
where U: Send + 'conn, Conn: AsyncConnection, Self: LimitDsl, Self::Output: LoadQuery<'query, Conn, U> + Send + 'query,

Attempts to load a single record. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T