#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TagValue(String);
impl TagValue {
pub fn escape_to_line_protocol(&self) -> String {
self.0
.replace(" ", "\\ ")
.replace(",", "\\,")
.replace("=", "\\=")
}
}
impl From<&str> for TagValue {
fn from(s: &str) -> Self {
Self(s.to_string())
}
}
impl From<String> for TagValue {
fn from(s: String) -> Self {
Self(s)
}
}
#[cfg(test)]
mod tests {
use super::*;
use quickcheck::{Arbitrary, Gen};
impl Arbitrary for TagValue {
fn arbitrary(g: &mut Gen) -> Self {
let value = String::arbitrary(g);
TagValue(value)
}
}
}