Skip to content

Commit

Permalink
refactor: replace SessionManager::new with Default derive
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Nov 26, 2024
1 parent 1f8fd05 commit 2434688
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/cord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ pub struct Cord {
impl Cord {
pub fn new(config: Config) -> crate::Result<Self> {
let (tx, rx) = mpsc::channel::<Message>();
let session_manager = SessionManager::default();
let rich_client = Arc::new(RichClient::connect(config.client_id)?);
let server = PipeServer::new(&config.pipe_name, tx.clone());
let logger = Logger::new(tx.clone(), LogLevel::Off);

Ok(Self {
config,
session_manager: SessionManager::new(),
session_manager,
rich_client,
pipe: server,
tx,
Expand Down
8 changes: 1 addition & 7 deletions src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,13 @@ impl<'a> std::ops::DerefMut for SessionRefMut<'a> {
}
}

#[derive(Default)]
pub struct SessionManager {
sessions: RwLock<HashMap<u32, Session>>,
default_config: Option<PluginConfig>,
}

impl SessionManager {
pub fn new() -> Self {
Self {
sessions: RwLock::new(HashMap::new()),
default_config: None,
}
}

pub fn create_session(&self, id: u32) {
let mut sessions = self.sessions.write().unwrap();
let session = Session::new(id);
Expand Down

0 comments on commit 2434688

Please sign in to comment.