rename: serde_percent::{Value => Percent}

This commit is contained in:
Christian Schwarz
2023-03-27 18:52:47 +02:00
parent e7d41c32ae
commit 504256a0cc
2 changed files with 7 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
//! A serde::Desierialize type for percentages.
//!
//! See [`Value`] for details.
//! See [`Percent`] for details.
use serde::{Deserialize, Serialize};
@@ -8,9 +8,9 @@ use serde::{Deserialize, Serialize};
/// deserialization fails with a descriptive error.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct Value(#[serde(deserialize_with = "deserialize_pct_0_to_100")] u8);
pub struct Percent(#[serde(deserialize_with = "deserialize_pct_0_to_100")] u8);
impl Value {
impl Percent {
pub fn get(&self) -> u8 {
self.0
}
@@ -31,11 +31,11 @@ where
#[cfg(test)]
mod tests {
use super::Value;
use super::Percent;
#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Eq)]
struct Foo {
bar: Value,
bar: Percent,
}
#[test]

View File

@@ -38,7 +38,7 @@ use sync_wrapper::SyncWrapper;
use tokio::time::Instant;
use tokio_util::sync::CancellationToken;
use tracing::{debug, error, info, instrument, warn, Instrument};
use utils::{approx_accurate::ApproxAccurate, id::TenantId, serde_percent};
use utils::{approx_accurate::ApproxAccurate, id::TenantId, serde_percent::Percent};
use crate::{
config::PageServerConf,
@@ -48,7 +48,7 @@ use crate::{
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DiskUsageEvictionTaskConfig {
pub max_usage_pct: serde_percent::Value,
pub max_usage_pct: Percent,
pub min_avail_bytes: u64,
#[serde(with = "humantime_serde")]
pub period: Duration,