diff --git a/rust/server/src/main.rs b/rust/server/src/main.rs index 5dcfa58..2b13a19 100644 --- a/rust/server/src/main.rs +++ b/rust/server/src/main.rs @@ -18,7 +18,8 @@ use hyper::server::conn::http1; use hyper_util::rt::TokioIo; use crate::vss_service::VssService; -use api::auth::NoopAuthorizer; +use api::auth::{Authorizer, NoopAuthorizer}; +use api::kv_store::KvStore; use impls::postgres_store::PostgresBackendImpl; use std::sync::Arc; @@ -58,7 +59,7 @@ fn main() { match res { Ok((stream, _)) => { let io_stream = TokioIo::new(stream); - let vss_service = VssService::new(Arc::clone(&store), Arc::clone(&authorizer)); + let vss_service = VssService::new(Arc::clone(&store) as Arc, Arc::clone(&authorizer) as Arc); runtime.spawn(async move { if let Err(err) = http1::Builder::new().serve_connection(io_stream, vss_service).await { eprintln!("Failed to serve connection: {}", err); diff --git a/rust/server/src/vss_service.rs b/rust/server/src/vss_service.rs index abf4833..60ecc12 100644 --- a/rust/server/src/vss_service.rs +++ b/rust/server/src/vss_service.rs @@ -19,30 +19,18 @@ use std::pin::Pin; use std::sync::Arc; #[derive(Clone)] -pub struct VssService -where - K: KvStore, - A: Authorizer, -{ - store: Arc, - authorizer: Arc, +pub struct VssService { + store: Arc, + authorizer: Arc, } -impl VssService -where - K: KvStore, - A: Authorizer, -{ - pub(crate) fn new(store: Arc, authorizer: Arc) -> Self { +impl VssService { + pub(crate) fn new(store: Arc, authorizer: Arc) -> Self { Self { store, authorizer } } } -impl Service> for VssService -where - K: KvStore + 'static, - A: Authorizer + 'static, -{ +impl Service> for VssService { type Response = Response>; type Error = hyper::Error; type Future = Pin> + Send>>; @@ -77,36 +65,35 @@ where } } -async fn handle_get_object_request( - store: Arc, user_token: String, request: GetObjectRequest, +async fn handle_get_object_request( + store: Arc, user_token: String, request: GetObjectRequest, ) -> Result { store.get(user_token, request).await } -async fn handle_put_object_request( - store: Arc, user_token: String, request: PutObjectRequest, +async fn handle_put_object_request( + store: Arc, user_token: String, request: PutObjectRequest, ) -> Result { store.put(user_token, request).await } -async fn handle_delete_object_request( - store: Arc, user_token: String, request: DeleteObjectRequest, +async fn handle_delete_object_request( + store: Arc, user_token: String, request: DeleteObjectRequest, ) -> Result { store.delete(user_token, request).await } -async fn handle_list_object_request( - store: Arc, user_token: String, request: ListKeyVersionsRequest, +async fn handle_list_object_request( + store: Arc, user_token: String, request: ListKeyVersionsRequest, ) -> Result { store.list_key_versions(user_token, request).await } async fn handle_request< T: Message + Default, R: Message, - F: FnOnce(Arc, String, T) -> Fut + Send, + F: FnOnce(Arc, String, T) -> Fut + Send + 'static, Fut: Future> + Send, - K: KvStore + 'static, - A: Authorizer + 'static, >( - store: Arc, authorizer: Arc, request: Request, handler: F, -) -> Result< as Service>>::Response, hyper::Error> { + store: Arc, authorizer: Arc, request: Request, + handler: F, +) -> Result<>>::Response, hyper::Error> { let (parts, body) = request.into_parts(); let headers_map = parts .headers