segment_rs/
client.rs

1use crate::connection::{Connection, ConnectionError, ConnectionOptions};
2
3#[derive(Debug)]
4/// Segment client
5pub struct Client {
6    options: ConnectionOptions,
7}
8
9impl Client {
10    /// Creates a new client, this does not create a new connection
11    pub fn new(options: ConnectionOptions) -> Self {
12        Client { options }
13    }
14
15    /// Creates a new connection
16    pub async fn get_connection(&self) -> Result<Connection, ConnectionError> {
17        Connection::connect(&self.options).await
18    }
19}