fix: Move NonEmptyString to data_types2
parent
6b0e7ae46a
commit
1ea4a40b1f
|
@ -17,7 +17,6 @@ mod database_name;
|
|||
pub mod database_rules;
|
||||
pub mod error;
|
||||
pub mod job;
|
||||
pub mod non_empty;
|
||||
pub mod partition_metadata;
|
||||
pub mod router;
|
||||
pub mod sequence;
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
use std::ops::Deref;
|
||||
|
||||
/// A string that cannot be empty
|
||||
///
|
||||
/// This is particularly useful for types that map to/from protobuf, where string fields
|
||||
/// are not nullable - that is they default to an empty string if not specified
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct NonEmptyString(Box<str>);
|
||||
|
||||
impl NonEmptyString {
|
||||
/// Create a new `NonEmptyString` from the provided `String`
|
||||
///
|
||||
/// Returns None if empty
|
||||
pub fn new(s: impl Into<String>) -> Option<Self> {
|
||||
let s = s.into();
|
||||
match s.is_empty() {
|
||||
true => None,
|
||||
false => Some(Self(s.into_boxed_str())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for NonEmptyString {
|
||||
type Target = str;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
|
@ -20,13 +20,12 @@ use std::{
|
|||
convert::TryFrom,
|
||||
fmt::Write,
|
||||
num::{FpCategory, NonZeroU32},
|
||||
ops::{Add, Sub},
|
||||
ops::{Add, Deref, Sub},
|
||||
sync::Arc,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub use data_types::{
|
||||
non_empty::NonEmptyString,
|
||||
partition_metadata::{
|
||||
ColumnSummary, InfluxDbType, PartitionAddr, StatValues, Statistics, TableSummary,
|
||||
},
|
||||
|
@ -1255,6 +1254,34 @@ pub fn org_and_bucket_to_database<'a, O: AsRef<str>, B: AsRef<str>>(
|
|||
DatabaseName::new(db_name).context(InvalidDatabaseNameSnafu)
|
||||
}
|
||||
|
||||
/// A string that cannot be empty
|
||||
///
|
||||
/// This is particularly useful for types that map to/from protobuf, where string fields
|
||||
/// are not nullable - that is they default to an empty string if not specified
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct NonEmptyString(Box<str>);
|
||||
|
||||
impl NonEmptyString {
|
||||
/// Create a new `NonEmptyString` from the provided `String`
|
||||
///
|
||||
/// Returns None if empty
|
||||
pub fn new(s: impl Into<String>) -> Option<Self> {
|
||||
let s = s.into();
|
||||
match s.is_empty() {
|
||||
true => None,
|
||||
false => Some(Self(s.into_boxed_str())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for NonEmptyString {
|
||||
type Target = str;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -12,12 +12,11 @@
|
|||
)]
|
||||
|
||||
use data_types::{
|
||||
non_empty::NonEmptyString,
|
||||
partition_metadata::{StatValues, Statistics},
|
||||
router::{ShardConfig, ShardId},
|
||||
sequence::Sequence,
|
||||
};
|
||||
use data_types2::DeletePredicate;
|
||||
use data_types2::{DeletePredicate, NonEmptyString};
|
||||
use hashbrown::HashMap;
|
||||
use iox_time::Time;
|
||||
use mutable_batch::MutableBatch;
|
||||
|
@ -491,7 +490,6 @@ mod tests {
|
|||
use crate::test_util::assert_writes_eq;
|
||||
use data_types::{
|
||||
consistent_hasher::ConsistentHasher,
|
||||
non_empty::NonEmptyString,
|
||||
router::{HashRing, Matcher, MatcherToShard},
|
||||
timestamp::TimestampRange,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Encode/Decode for messages
|
||||
|
||||
use crate::core::WriteBufferError;
|
||||
use data_types::{non_empty::NonEmptyString, sequence::Sequence};
|
||||
use data_types2::{NonEmptyString, Sequence};
|
||||
use dml::{DmlDelete, DmlMeta, DmlOperation, DmlWrite};
|
||||
use generated_types::{
|
||||
google::FromOptionalField,
|
||||
|
|
Loading…
Reference in New Issue