From 492cf38cbb67d14d7a4b56aba3076fcc37e8967d Mon Sep 17 00:00:00 2001 From: Max Audron Date: Tue, 4 Oct 2022 09:16:26 +0200 Subject: derive default for all signalproxy objects and make singalmessage class an enum --- src/message/signalproxy/objects/network.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/message/signalproxy/objects/network.rs') diff --git a/src/message/signalproxy/objects/network.rs b/src/message/signalproxy/objects/network.rs index 4985bd9..266a1be 100644 --- a/src/message/signalproxy/objects/network.rs +++ b/src/message/signalproxy/objects/network.rs @@ -29,6 +29,14 @@ pub struct Network { } impl Network { + pub fn get_channel_mode_type(&self, mode: char) -> ChannelModeType { + if let Some((mode_type, _)) = self.channel_modes.iter().find(|(_, v)| v.contains(mode)) { + *mode_type + } else { + ChannelModeType::NotAChanmode + } + } + /// The `channel_modes` field is populated by the ``supports["CHANMODES"]` string, /// which is represented as the channel mode types a,b,c,d in a comma sepperated string. fn determine_channel_mode_types(&mut self) { @@ -382,6 +390,20 @@ mod tests { assert_eq!(network.channel_modes.get(&ChannelModeType::DChanmode).unwrap(), "ABCDKMNOPQRSTcimnprstuz"); } + #[test] + fn network_get_channel_mode_type() { + let mut network = Network::default(); + + network.supports.insert(s!("CHANMODES"), s!("IXZbegw,k,FHJLWdfjlx,ABCDKMNOPQRSTcimnprstuz")); + network.determine_channel_mode_types(); + + assert_eq!(network.get_channel_mode_type('b'), ChannelModeType::AChanmode); + assert_eq!(network.get_channel_mode_type('k'), ChannelModeType::BChanmode); + assert_eq!(network.get_channel_mode_type('W'), ChannelModeType::CChanmode); + assert_eq!(network.get_channel_mode_type('D'), ChannelModeType::DChanmode); + assert_eq!(network.get_channel_mode_type('E'), ChannelModeType::NotAChanmode); + } + #[test] fn network_determine_prefixes() { let mut network = Network::default(); @@ -418,9 +440,9 @@ impl Default for ConnectionState { } #[allow(dead_code)] -#[derive(Debug, Clone, Eq, Hash, PartialEq, FromPrimitive, ToPrimitive)] +#[derive(Debug, Copy, Clone, Eq, Hash, PartialEq, FromPrimitive, ToPrimitive)] #[repr(C)] -enum ChannelModeType { +pub enum ChannelModeType { NotAChanmode = 0x00, AChanmode = 0x01, BChanmode = 0x02, -- cgit v1.2.3 ion>
path: root/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_gen/core/v1/event.libsonnet (unfollow)
Commit message (Expand)AuthorLines
2025-12-17add twitter cancel featureMax Audron-7/+44
2025-12-14update debug config filesMax Audron-7/+6
2025-12-14release 1.7.11.7.1Max Audron-2/+2
2025-12-14fix non-sasl connection registrationMax Audron-9/+35
2025-12-14fix readme badge linksMax Audron-3/+3
2025-12-14update readme and remotesMax Audron-1/+14
2025-12-14release 1.7.01.7.0Max Audron-2/+2
2025-12-14add server passwordMax Audron-1/+6
2025-12-14update cargo dependenciesMax Audron-670/+505
2025-12-14update flake inputs to nixpkgs 25.11Max Audron-36/+41
2025-05-06fix rustls missing cryptoproviderMax Audron-1/+6
2025-05-06remove too commonly used used for shifty_eyesMax Audron-1/+1
2025-05-06fix truncate on unicodeMax Audron-10/+20
2025-05-06update dependenciesMax Audron-691/+1659
2024-08-12add nix build and moduleMax Audron-5/+427
2022-02-19remove jsonnet lock fileMax Audron-36/+0
2022-02-19fix deploy to work with gitlab agentMax Audron-4/+4
2021-10-22write tons of documentation and reorganize some modulesMax Audron-65/+300
2021-10-22remove wolfram alpha url shorteningMax Audron-1/+2
2021-10-20remove failing wolfram alpha test casesMax Audron-105/+55
2021-10-20bump version to 1.6.2Max Audron-3/+2
2021-10-20prepare for release on crates.ioMax Audron-39/+65
2021-10-20add async docs to macro crate and bump versionMax Audron-9/+10
2021-10-20change hook errors to be logged as warningsMax Audron-3/+3
2021-10-20fix configuration not loading correctly on release buildsMax Audron-8/+23
2021-10-19replace sedregex crate8-rework-sedMax Audron-20/+358
2021-10-19add formatting trait for irc codesMax Audron-0/+129
2021-10-17fix links in readmeMax Audron-2/+2