Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
spencewenski committed Jun 29, 2024
1 parent 2de1518 commit e5b0714
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/full/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl RoadsterApp<AppContext> for App {
.build())
}

async fn provide_state(_context: AppContext) -> RoadsterResult<Self::State> {
async fn provide_state(_context: AppContext) -> RoadsterResult<AppContext> {
Ok(_context)
}

Expand Down
25 changes: 6 additions & 19 deletions examples/full/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use crate::app::App;
use async_trait::async_trait;
use clap::{Parser, Subcommand};
use roadster::app::context::AppContext;

use roadster::api::cli::RunCommand;
use roadster::app::context::AppContext;
use roadster::error::RoadsterResult;

use crate::app::App;
use crate::app_state::CustomAppContext;

/// Full Example: Commands specific to managing the `full` app are provided in the CLI
/// as well. Subcommands not listed under the `roadster` subcommand are specific to `full`.
#[derive(Debug, Parser)]
Expand All @@ -19,14 +16,9 @@ pub struct AppCli {
}

#[async_trait]
impl RunCommand<App> for AppCli {
impl RunCommand<App, AppContext> for AppCli {
#[allow(clippy::disallowed_types)]
async fn run(
&self,
app: &App,
cli: &AppCli,
context: &AppContext<CustomAppContext>,
) -> RoadsterResult<bool> {
async fn run(&self, app: &App, cli: &AppCli, context: &AppContext) -> RoadsterResult<bool> {
if let Some(command) = self.command.as_ref() {
command.run(app, cli, context).await
} else {
Expand All @@ -42,13 +34,8 @@ impl RunCommand<App> for AppCli {
pub enum AppCommand {}

#[async_trait]
impl RunCommand<App> for AppCommand {
async fn run(
&self,
_app: &App,
_cli: &AppCli,
_context: &AppContext<CustomAppContext>,
) -> RoadsterResult<bool> {
impl RunCommand<App, AppContext> for AppCommand {
async fn run(&self, _app: &App, _cli: &AppCli, _context: &AppContext) -> RoadsterResult<bool> {
Ok(false)
}
}
3 changes: 1 addition & 2 deletions examples/full/src/worker/example.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::app::App;
use async_trait::async_trait;
use roadster::app::context::AppContext;
use roadster::service::worker::sidekiq::app_worker::AppWorker;
Expand All @@ -17,7 +16,7 @@ impl Worker<String> for ExampleWorker {
}

#[async_trait]
impl AppWorker<_, String> for ExampleWorker {
impl AppWorker<AppContext, String> for ExampleWorker {
fn build(_context: &AppContext) -> Self {
Self {}
}
Expand Down
3 changes: 1 addition & 2 deletions src/service/http/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ where

impl HttpService {
/// Create a new [HttpServiceBuilder].
pub fn builder<A, S>(path_root: Option<&str>, context: &S) -> HttpServiceBuilder<S>
pub fn builder<S>(path_root: Option<&str>, context: &S) -> HttpServiceBuilder<S>
where
S: Clone + Send + Sync + 'static,
AppContext: FromRef<S>,
A: App<S>,
{
HttpServiceBuilder::new(path_root, context)
}
Expand Down

0 comments on commit e5b0714

Please sign in to comment.