aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
530 stars 97 forks source link

Add public function to view server chanlist? #82

Closed sector-f closed 7 years ago

sector-f commented 7 years ago

IrcServer has a ServerState, and ServerState has chanlists: Mutex<HashMap<String, Vec<User>>>...but ServerState isn't pub.

I personally think it'd be really nice if IrcServer provided a method I could use to get a HashMap<String, Vec<User>>. Is that as feasible as I'm hoping?

aatxe commented 7 years ago

It provides the ability to list users for a particular channel through the Server trait function list_users. Is this what you were looking for? Or do you have an application that requires directly getting at the HashMap for one reason or another?

sector-f commented 7 years ago

If I'm understanding everything right: list_users requires I pass it a channel name as an argument, meaning that I have to keep track of the channels the client is currently connected to. But the IrcServer already keeps track of that. At risk of sounding lazy, why should I have to write code to keep track of the current channels when the irc crate is already doing it?

aatxe commented 7 years ago

Sure, I originally did just list users to avoid requiring the implementation to be a HashMap, but it sounds like it makes sense to be able to return a list of the channels as well. I'll implement this ASAP.

aatxe commented 7 years ago

I've implemented this in commit 38c7ed2c71d2b34a3104fbc8337ca645ae1353ca and it is live in 0.11.8.