From df4e942c453e73123910aafa643969a09cab24a1 Mon Sep 17 00:00:00 2001 From: Mehul <65443164+infiniteregrets@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:49:17 -0500 Subject: [PATCH] chore: rm serde (#99) closes #92 --- Cargo.toml | 2 -- src/types.rs | 56 ---------------------------------------------------- 2 files changed, 58 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0d405a..0775510 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ prost = "0.13.3" prost-types = "0.13.3" regex = "1.11.1" secrecy = "0.8.0" -serde = { version = "1.0.214", optional = true, features = ["derive"] } sync_docs = { path = "sync_docs" } thiserror = "1.0.67" tokio = { version = "1.41.1", features = ["time"] } @@ -42,7 +41,6 @@ tokio = { version = "1.41.1", features = ["full", "test-util"] } tokio-stream = "0.1.16" [features] -serde = ["dep:serde"] connector = [] [lints.clippy] diff --git a/src/types.rs b/src/types.rs index 8dff06a..171c9f7 100644 --- a/src/types.rs +++ b/src/types.rs @@ -2,8 +2,6 @@ use std::{ops::Deref, str::FromStr, sync::OnceLock, time::Duration}; use bytes::Bytes; use regex::Regex; -#[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; use sync_docs::sync_docs; use crate::api; @@ -49,7 +47,6 @@ macro_rules! metered_impl { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct CreateBasinRequest { pub basin: BasinName, @@ -85,7 +82,6 @@ impl From for api::CreateBasinRequest { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, Default)] pub struct BasinConfig { pub default_stream_config: Option, @@ -127,7 +123,6 @@ impl TryFrom for BasinConfig { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, Default)] pub struct StreamConfig { pub storage_class: StorageClass, @@ -182,7 +177,6 @@ impl TryFrom for StreamConfig { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub enum StorageClass { #[default] @@ -239,7 +233,6 @@ impl TryFrom for StorageClass { } #[sync_docs(Age = "AgeMillis")] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub enum RetentionPolicy { Age(Duration), @@ -262,7 +255,6 @@ impl From for RetentionPolicy { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum BasinState { Unspecified, @@ -320,7 +312,6 @@ impl std::fmt::Display for BasinState { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct BasinInfo { pub name: String, @@ -374,7 +365,6 @@ impl TryFrom for BasinInfo { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, Default)] pub struct ListStreamsRequest { pub prefix: String, @@ -428,7 +418,6 @@ impl TryFrom for api::ListStreamsRequest { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct StreamInfo { pub name: String, @@ -447,7 +436,6 @@ impl From for StreamInfo { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct ListStreamsResponse { pub streams: Vec, @@ -481,7 +469,6 @@ impl TryFrom for StreamConfig { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct CreateStreamRequest { pub stream: String, @@ -515,7 +502,6 @@ impl From for api::CreateStreamRequest { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, Default)] pub struct ListBasinsRequest { pub prefix: String, @@ -569,7 +555,6 @@ impl TryFrom for api::ListBasinsRequest { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct ListBasinsResponse { pub basins: Vec, @@ -591,7 +576,6 @@ impl TryFrom for ListBasinsResponse { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct DeleteBasinRequest { pub basin: BasinName, @@ -620,7 +604,6 @@ impl From for api::DeleteBasinRequest { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct DeleteStreamRequest { pub stream: String, @@ -649,7 +632,6 @@ impl From for api::DeleteStreamRequest { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct ReconfigureBasinRequest { pub basin: BasinName, @@ -706,7 +688,6 @@ impl TryFrom for BasinConfig { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct ReconfigureStreamRequest { pub stream: String, @@ -809,41 +790,6 @@ impl From for Header { #[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct FencingToken(Bytes); -#[cfg(feature = "serde")] -impl Serialize for FencingToken { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - use std::fmt::Write; - - let mut bytes_str = "0x".to_owned(); - for b in self.0.iter() { - write!(&mut bytes_str, "{:02x}", b).expect("writing to string"); - } - serializer.serialize_str(&bytes_str) - } -} - -#[cfg(feature = "serde")] -impl<'de> Deserialize<'de> for FencingToken { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - use serde::de::Error; - - let bytes_str = String::deserialize(deserializer)?; - let bytes = if let Some(bytes) = Self::try_from_hex_bytes(&bytes_str) { - bytes.map_err(D::Error::custom)? - } else { - bytes_str.into() - }; - - Self::new(bytes).map_err(D::Error::custom) - } -} - impl FencingToken { const MAX_BYTES: usize = 16; @@ -947,7 +893,6 @@ impl TryFrom> for FencingToken { } #[sync_docs] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub enum CommandRecord { Fence { fencing_token: FencingToken }, @@ -1570,7 +1515,6 @@ impl TryFrom for ReadOutput { } } -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone)] pub struct BasinName(String);