1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
pub mod message;
pub mod number;

use std::{borrow::Cow, fmt::Display};

use crate::error::Result;

pub trait DataType<T>: Display + TryInto<T> {
    /// Get the actual value that the inner byte slice is representing.
    fn value(&self) -> Result<T>;

    /// Get the value as a raw string, before actual parsing.
    fn as_str(&self) -> Result<&str>;
    /// Get the value as a raw string in lossless fashion, before actual parsing.
    fn as_str_lossy(&self) -> Cow<'_, str>;

    /// The raw slice that represents the data.
    fn raw(&self) -> &[u8];
}