value: Implement Value for HashSet
It doesn't matter that the values are not serialized in sorted order.
Scylla should sort each set it receives from the driver.
@@ -4,7 +4,7 @@ use chrono::prelude::*;
use chrono::Duration;
use num_bigint::BigInt;
use std::borrow::Cow;
-use std::collections::HashMap;
+use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
use std::net::IpAddr;
use thiserror::Error;
@@ -467,6 +467,12 @@ fn serialize_list_or_set<'a, V: 'a + Value>(
Ok(())
}
+impl<V: Value> Value for HashSet<V> {
+ fn serialize(&self, buf: &mut Vec<u8>) -> Result<(), ValueTooBig> {
+ serialize_list_or_set(self.iter(), self.len(), buf)
+ }
+}
+
impl<K: Value, V: Value> Value for HashMap<K, V> {
fn serialize(&self, buf: &mut Vec<u8>) -> Result<(), ValueTooBig> {
serialize_map(self.iter(), self.len(), buf)
