Skip to content

Commit

Permalink
Merge pull request #85 from 4t145/fix-recover-void-def
Browse files Browse the repository at this point in the history
fix: re-export the type `Directive`, deserialize any value into `Void`.
  • Loading branch information
4t145 authored Oct 25, 2023
2 parents 8eb6e67 + fc2949f commit 7ee6a6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tardis/src/basic/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::sync::Once;
use crate::basic::result::TardisResult;
use crate::config::config_dto::LogConfig;

use crate::TARDIS_INST;

#[allow(unused_imports)]
use crate::consts::*;
use crate::TARDIS_INST;
pub use tracing_subscriber::filter::Directive;
use tracing_subscriber::layer::Layered;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::EnvFilter;
Expand Down
15 changes: 14 additions & 1 deletion tardis/src/web/web_resp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,18 @@ where
pub records: Vec<T>,
}

#[derive(Object, Deserialize, Serialize, Clone, Debug, Default, Copy)]
#[derive(Object, Serialize, Clone, Debug, Default, Copy)]
/// This `Void` is for represent an empty value.
/// Any value can be deserialized as `Void`.
/// Void will be serialized as json's `null`.
pub struct Void;
impl<'de> Deserialize<'de> for Void {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
// ignore this value whatever
let _ = deserializer.deserialize_any(serde::de::IgnoredAny)?;
Ok(Void)
}
}

0 comments on commit 7ee6a6b

Please sign in to comment.