aboutsummaryrefslogtreecommitdiff
path: root/src/primitive/variant.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2023-12-20 13:13:00 +0100
committerMax Audron <audron@cocaine.farm>2023-12-20 13:13:00 +0100
commite6980211c4c53fc1eeb686cd12363a8fa603daa3 (patch)
tree2c248fc32d258dea722dbbefd7ab5465954e2ebc /src/primitive/variant.rs
parentuse VariantMap as target for generic NetworkMap for HashMap impl (diff)
rework Network derives to be more consistent
i don't even know anymore, blame past me
Diffstat (limited to 'src/primitive/variant.rs')
-rw-r--r--src/primitive/variant.rs32
1 files changed, 3 insertions, 29 deletions
diff --git a/src/primitive/variant.rs b/src/primitive/variant.rs
index 673d39f..b306ea7 100644
--- a/src/primitive/variant.rs
+++ b/src/primitive/variant.rs
@@ -86,38 +86,12 @@ impl From<&str> for Variant {
/// Implements the Network trait genericly for everything that
/// can be a VariantList / Vec<T>
-impl<T> crate::message::Network for Vec<T>
-where
- T: std::convert::TryFrom<Variant> + Into<Variant> + Clone,
-{
- type Item = super::VariantList;
-
- fn to_network(&self) -> Self::Item {
- self.iter().map(|i| (*i).clone().into()).collect()
- }
-
- fn from_network(input: &mut Self::Item) -> Self {
- input
- .iter()
- .map(|i| match T::try_from(i.clone()) {
- Ok(it) => it,
- // TODO handle error
- _ => unreachable!(),
- })
- .collect()
- }
-}
-
-/// Implements the Network trait genericly for everything that
-/// can be a VariantList / Vec<T>
-impl<T, S> crate::message::Network for HashMap<T, S>
+impl<T, S> crate::message::NetworkList for HashMap<T, S>
where
T: std::convert::TryFrom<Variant> + Into<Variant> + Clone + std::hash::Hash + std::cmp::Eq,
S: std::convert::TryFrom<Variant> + Into<Variant> + Clone + std::hash::Hash + std::cmp::Eq,
{
- type Item = super::VariantList;
-
- fn to_network(&self) -> Self::Item {
+ fn to_network_list(&self) -> VariantList {
let mut res = Vec::with_capacity(self.len() * 2);
self.iter().for_each(|(k, v)| {
@@ -128,7 +102,7 @@ where
return res;
}
- fn from_network(input: &mut Self::Item) -> Self {
+ fn from_network_list(input: &mut VariantList) -> Self {
let mut res = HashMap::with_capacity(input.len() / 2);
input.iter().tuples().for_each(|(k, v)| {
w=1'>publish macros subcrateMax Audron-20/+20 2021-06-13release version 1.2.1Max Audron-2/+2 2021-06-13fix crash on message only containing whitespaceMax Audron-1/+4 2021-06-11Release version 1.2.01.2.0Max Audron-2/+2 2021-06-06make pet more compactR0flcopt3r/catinator-pet-commandMax Audron-5/+5 2021-06-05feat: adds pet command.R0flcopt3r-0/+90 2021-06-05feat: send actionR0flcopt3r-1/+9 2021-06-05release version 1.1.0Max Audron-2/+2 2021-06-05document proc macrosMax Audron-4/+97 2021-06-05add intensifyMax Audron-3/+27 2021-06-05add privmsg macroMax Audron-2/+40 2021-06-05fix jb remote urlsMax Audron-4/+4 2021-06-05remove egress gateway configMax Audron-10/+0 2021-06-05update tanka dependenciesMax Audron-8/+8 2021-06-05fix init container nameMax Audron-1/+1 2021-06-05fix tanka dependency pathMax Audron-8/+8 2021-06-05switch to https url for tanka util libMax Audron-2/+2 2021-06-05bump version to 1.0.2Max Audron-2/+2 2021-06-05add tanka ci configurationMax Audron-1/+1 2021-06-05ready tanka deploy for CIMax Audron-32/+69 2021-06-05remove tanka vendoringMax Audron-27651/+0 2021-05-26Release 1.0.1Max Audron-3/+3 2021-05-26fix log breaking once buffer fullMax Audron-2/+33 2021-05-16add deployment stuffMax Audron-6/+27786 2021-05-15add container buildMax Audron-2/+35