use super::json::GrammarError;
use super::types::Grammar;
impl Grammar {
pub fn from_binary(bytes: &[u8]) -> Result<Self, GrammarError> {
postcard::from_bytes(bytes).map_err(GrammarError::Binary)
}
pub fn to_binary(&self) -> Vec<u8> {
postcard::to_allocvec(self).expect("serialization should not fail")
}
}