Skip to content

Commit

Permalink
feat: Add Clone trait for qbit (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
milad00ahmadi authored Oct 29, 2024
1 parent 89545de commit de1c53e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::{ext::*, model::*};
mod builder;
mod ext;

#[derive(Clone)]
enum LoginState {
CookieProvided {
cookie: String,
Expand Down Expand Up @@ -76,6 +77,7 @@ pub struct Qbit {
state: Mutex<LoginState>,
}


impl Qbit {
/// Create a new [`QbitBuilder`] to build a [`Qbit`] instance.
pub fn builder() -> QbitBuilder {
Expand Down Expand Up @@ -1505,6 +1507,13 @@ impl Qbit {
}
}

impl Clone for Qbit {
fn clone(&self) -> Self {
let state = self.state.lock().unwrap().clone();
Self { client: self.client.clone(), endpoint: self.endpoint.clone(), state: Mutex::new(state) }
}
}

const NONE: Option<&'static ()> = Option::None;

#[derive(Debug, thiserror::Error)]
Expand Down

0 comments on commit de1c53e

Please sign in to comment.