rcfe 0.1.2

An asynchronous etcd v3 client library for Rust built on gRPC.
Documentation
use tonic::async_trait;
use rcfe_core::{
    error::Error,
    factory::ClientFactory,
    options::client::ClientOptions
};
use crate::client::DefaultClient;

/// A default implementation of the ClientFactory trait for creating DefaultClient instances.
/// # Examples
/// ```rust
/// use rcfe_core::{
///     ClientFactory,
///     ClientOptions,
///     DefaultClientFactory,
///     Error
/// };
/// #[tokio::main]
/// async fn main() -> Result<(), Error> {
///     let factory = DefaultClientFactory;
///     let options = ClientOptions::builder()
///         .endpoints(vec!["http://localhost:2379"])
///         .build();
///
///     let client = factory.create(options).await?;
///     println!("Client created with options: {:?}", client.get_options());
///     Ok(())
/// }
/// ```
pub struct DefaultClientFactory;

impl DefaultClientFactory {
    pub fn new() -> Self {
        DefaultClientFactory
    }
}

#[async_trait]
impl ClientFactory<DefaultClient> for DefaultClientFactory {
    async fn create(&self, opts: ClientOptions) -> Result<DefaultClient, Error> {
        Ok(DefaultClient::new(opts)?)
    }
}