From efef543200bfcf5f7ec43d84a5ed8c8c6eaa5923 Mon Sep 17 00:00:00 2001 From: Paul Butler Date: Sun, 5 May 2024 12:22:54 -0400 Subject: [PATCH] Add default factory --- stateroom/src/lib.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/stateroom/src/lib.rs b/stateroom/src/lib.rs index c42b083..ecfd051 100644 --- a/stateroom/src/lib.rs +++ b/stateroom/src/lib.rs @@ -63,7 +63,7 @@ //! } //! } -use std::sync::Arc; +use std::{convert::Infallible, sync::Arc}; pub use client_id::ClientId; pub use message_recipient::MessageRecipient; @@ -137,3 +137,20 @@ pub trait StateroomServiceFactory: Send + Sync + 'static { context: Arc, ) -> Result; } + +pub struct DefaultStateroomFactory { + _marker: std::marker::PhantomData, +} + +impl StateroomServiceFactory for DefaultStateroomFactory { + type Service = T; + type Error = Infallible; + + fn build( + &self, + _: &str, + _: Arc, + ) -> Result { + Ok(T::default()) + } +}