Skip to content

Commit

Permalink
chore: rm serde (#99)
Browse files Browse the repository at this point in the history
closes #92
  • Loading branch information
infiniteregrets authored Dec 9, 2024
1 parent 8f69951 commit df4e942
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 58 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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]
Expand Down
56 changes: 0 additions & 56 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -85,7 +82,6 @@ impl From<CreateBasinRequest> for api::CreateBasinRequest {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Default)]
pub struct BasinConfig {
pub default_stream_config: Option<StreamConfig>,
Expand Down Expand Up @@ -127,7 +123,6 @@ impl TryFrom<api::BasinConfig> for BasinConfig {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Default)]
pub struct StreamConfig {
pub storage_class: StorageClass,
Expand Down Expand Up @@ -182,7 +177,6 @@ impl TryFrom<api::StreamConfig> for StreamConfig {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum StorageClass {
#[default]
Expand Down Expand Up @@ -239,7 +233,6 @@ impl TryFrom<i32> for StorageClass {
}

#[sync_docs(Age = "AgeMillis")]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub enum RetentionPolicy {
Age(Duration),
Expand All @@ -262,7 +255,6 @@ impl From<api::stream_config::RetentionPolicy> for RetentionPolicy {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BasinState {
Unspecified,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -374,7 +365,6 @@ impl TryFrom<api::CreateBasinResponse> for BasinInfo {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Default)]
pub struct ListStreamsRequest {
pub prefix: String,
Expand Down Expand Up @@ -428,7 +418,6 @@ impl TryFrom<ListStreamsRequest> for api::ListStreamsRequest {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct StreamInfo {
pub name: String,
Expand All @@ -447,7 +436,6 @@ impl From<api::StreamInfo> for StreamInfo {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct ListStreamsResponse {
pub streams: Vec<StreamInfo>,
Expand Down Expand Up @@ -481,7 +469,6 @@ impl TryFrom<api::GetStreamConfigResponse> for StreamConfig {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct CreateStreamRequest {
pub stream: String,
Expand Down Expand Up @@ -515,7 +502,6 @@ impl From<CreateStreamRequest> for api::CreateStreamRequest {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Default)]
pub struct ListBasinsRequest {
pub prefix: String,
Expand Down Expand Up @@ -569,7 +555,6 @@ impl TryFrom<ListBasinsRequest> for api::ListBasinsRequest {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct ListBasinsResponse {
pub basins: Vec<BasinInfo>,
Expand All @@ -591,7 +576,6 @@ impl TryFrom<api::ListBasinsResponse> for ListBasinsResponse {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct DeleteBasinRequest {
pub basin: BasinName,
Expand Down Expand Up @@ -620,7 +604,6 @@ impl From<DeleteBasinRequest> for api::DeleteBasinRequest {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct DeleteStreamRequest {
pub stream: String,
Expand Down Expand Up @@ -649,7 +632,6 @@ impl From<DeleteStreamRequest> for api::DeleteStreamRequest {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct ReconfigureBasinRequest {
pub basin: BasinName,
Expand Down Expand Up @@ -706,7 +688,6 @@ impl TryFrom<api::ReconfigureBasinResponse> for BasinConfig {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct ReconfigureStreamRequest {
pub stream: String,
Expand Down Expand Up @@ -809,41 +790,6 @@ impl From<api::Header> for Header {
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct FencingToken(Bytes);

#[cfg(feature = "serde")]
impl Serialize for FencingToken {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
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<D>(deserializer: D) -> Result<Self, D::Error>
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;

Expand Down Expand Up @@ -947,7 +893,6 @@ impl TryFrom<Vec<u8>> for FencingToken {
}

#[sync_docs]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub enum CommandRecord {
Fence { fencing_token: FencingToken },
Expand Down Expand Up @@ -1570,7 +1515,6 @@ impl TryFrom<api::ReadSessionResponse> for ReadOutput {
}
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct BasinName(String);

Expand Down

0 comments on commit df4e942

Please sign in to comment.