PreDomain
This commit is contained in:
parent
23943f8b14
commit
8b7baec26b
|
@ -11,7 +11,7 @@ pub mod value;
|
|||
#[cfg(test)]
|
||||
mod dom {
|
||||
use super::value::{
|
||||
Value, IOValue, IOResult, NestedValue, PlainValue, Domain,
|
||||
Value, IOValue, IOResult, NestedValue, PlainValue, PreDomain, Domain,
|
||||
PackedWriter,
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,8 @@ mod dom {
|
|||
Two,
|
||||
}
|
||||
|
||||
impl Domain for Dom {
|
||||
impl Domain for Dom {}
|
||||
impl PreDomain for Dom {
|
||||
fn from_preserves(v: IOValue) -> IOResult<Self> {
|
||||
panic!("Cannot decode IOValue to Dom: {:?}", v);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ pub use repr::IOValue;
|
|||
pub use repr::Map;
|
||||
pub use repr::NestedValue;
|
||||
pub use repr::PlainValue;
|
||||
pub use repr::PreDomain;
|
||||
pub use repr::RcValue;
|
||||
pub use repr::Record;
|
||||
pub use repr::Set;
|
||||
|
|
|
@ -21,12 +21,15 @@ use super::IOResult;
|
|||
use super::signed_integer::SignedInteger;
|
||||
use crate::error::{Error, ExpectedKind, Received};
|
||||
|
||||
pub trait Domain: Sized + Debug + Clone + Eq + Hash + Ord {
|
||||
pub trait PreDomain: Sized + Debug + Eq + Hash + Ord {
|
||||
fn from_preserves(v: IOValue) -> IOResult<Self>;
|
||||
fn as_preserves(&self) -> IOValue;
|
||||
}
|
||||
|
||||
impl<D: Domain> Domain for Arc<D> {
|
||||
pub trait Domain: PreDomain + Clone {}
|
||||
|
||||
impl<D: PreDomain> Domain for Arc<D> {}
|
||||
impl<D: PreDomain> PreDomain for Arc<D> {
|
||||
fn from_preserves(v: IOValue) -> IOResult<Self> {
|
||||
Ok(Arc::new(D::from_preserves(v)?))
|
||||
}
|
||||
|
@ -1109,7 +1112,8 @@ impl<'de, Dom: Domain> serde::Deserialize<'de> for ArcValue<Dom> {
|
|||
pub struct IOValue(Arc<AnnotatedValue<IOValue, IOValue>>);
|
||||
pub type UnwrappedIOValue = Value<IOValue, IOValue>;
|
||||
|
||||
impl Domain for IOValue {
|
||||
impl Domain for IOValue {}
|
||||
impl PreDomain for IOValue {
|
||||
fn from_preserves(v: IOValue) -> IOResult<Self> {
|
||||
Ok(v)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue