From a3e14b3d7380cfe1d0c6a1649def7fce2dd156e7 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Wed, 20 Dec 2023 14:03:08 +0100 Subject: fix ignorelistmanager enum conversions --- .../signalproxy/objects/ignorelistmanager.rs | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/message/signalproxy/objects/ignorelistmanager.rs b/src/message/signalproxy/objects/ignorelistmanager.rs index 7050bdd..ce4ad43 100644 --- a/src/message/signalproxy/objects/ignorelistmanager.rs +++ b/src/message/signalproxy/objects/ignorelistmanager.rs @@ -4,6 +4,7 @@ use crate::{ }; use libquassel_derive::{sync, NetworkList, NetworkMap}; +use num_derive::{FromPrimitive, ToPrimitive}; #[derive(Default, Debug, Clone, PartialEq, NetworkList, NetworkMap)] pub struct IgnoreListManager { @@ -201,8 +202,10 @@ pub struct IgnoreListItem { ////////////////////////////////////// +use num_traits::{FromPrimitive, ToPrimitive}; + #[repr(i32)] -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, FromPrimitive, ToPrimitive)] pub enum IgnoreType { SenderIgnore = 0x00, MessageIgnore = 0x01, @@ -211,19 +214,19 @@ pub enum IgnoreType { impl From for Variant { fn from(value: IgnoreType) -> Self { - Variant::i32(value as i32) + Variant::i32(value.to_i32().unwrap()) } } impl From for IgnoreType { fn from(value: Variant) -> Self { - IgnoreType::try_from(value).unwrap() + IgnoreType::from_i32(value.try_into().unwrap()).unwrap() } } impl From for i32 { fn from(value: IgnoreType) -> Self { - value as i32 + value.to_i32().unwrap() } } @@ -241,7 +244,7 @@ impl TryFrom for IgnoreType { } #[repr(i32)] -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, FromPrimitive, ToPrimitive)] pub enum StrictnessType { UnmatchedStrictness = 0x00, SoftStrictness = 0x01, @@ -250,19 +253,19 @@ pub enum StrictnessType { impl From for Variant { fn from(value: StrictnessType) -> Self { - Variant::i32(value as i32) + Variant::i32(value.to_i32().unwrap()) } } impl From for StrictnessType { fn from(value: Variant) -> Self { - StrictnessType::try_from(value).unwrap() + StrictnessType::from_i32(value.try_into().unwrap()).unwrap() } } impl From for i32 { fn from(value: StrictnessType) -> Self { - value as i32 + value.to_i32().unwrap() } } @@ -280,7 +283,7 @@ impl TryFrom for StrictnessType { } #[repr(i32)] -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, FromPrimitive, ToPrimitive)] pub enum ScopeType { GlobalScope = 0x00, NetworkScope = 0x01, @@ -289,19 +292,19 @@ pub enum ScopeType { impl From for Variant { fn from(value: ScopeType) -> Self { - Variant::i32(value as i32) + Variant::i32(value.to_i32().unwrap()) } } impl From for ScopeType { fn from(value: Variant) -> Self { - ScopeType::try_from(value).unwrap() + ScopeType::from_i32(value.try_into().unwrap()).unwrap() } } impl From for i32 { fn from(value: ScopeType) -> Self { - value as i32 + value.to_i32().unwrap() } } -- cgit v1.2.3 a href='/catinator.git/log/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_gen?h=1.7.1&follow=1'>_gen/node/v1beta1/overhead.libsonnet (unfollow)
Commit message (Expand)AuthorLines
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