use serde::{Deserialize, Serialize};
use crate::compat::string::String;
use crate::compat::vec::Vec;
use crate::{deserialize, serialize, Decodable, Encodable, Encoded, Message};
#[derive(Serialize, Deserialize, Debug, Clone, Hash, Ord, PartialOrd, Eq, PartialEq, Message)]
pub struct LocalInfo {
type_identifier: String,
data: Vec<u8>,
}
impl LocalInfo {
pub fn new(type_identifier: String, data: Vec<u8>) -> Self {
LocalInfo {
type_identifier,
data,
}
}
}
impl LocalInfo {
pub fn type_identifier(&self) -> &str {
&self.type_identifier
}
pub fn data(&self) -> &[u8] {
&self.data
}
}
impl Encodable for LocalInfo {
fn encode(self) -> crate::Result<Encoded> {
serialize(self)
}
}
impl Decodable for LocalInfo {
fn decode(e: &[u8]) -> crate::Result<Self> {
deserialize(e)
}
}