Serialization of Signed and Main Pods (#128)
This commit is contained in:
parent
fee70af12b
commit
9afc43675d
16 changed files with 817 additions and 189 deletions
|
|
@ -1,18 +1,18 @@
|
|||
use std::fmt;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use log::error;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
|
||||
use super::{CustomPredicateRef, NativePredicate, Statement, StatementArg};
|
||||
use crate::middleware::{AnchoredKey, Params, Predicate, Value, SELF};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum OperationType {
|
||||
Native(NativeOperation),
|
||||
Custom(CustomPredicateRef),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum NativeOperation {
|
||||
None = 0,
|
||||
NewEntry = 1,
|
||||
|
|
@ -91,7 +91,7 @@ pub enum Operation {
|
|||
}
|
||||
|
||||
impl Operation {
|
||||
pub fn code(&self) -> OperationType {
|
||||
pub fn predicate(&self) -> OperationType {
|
||||
type OT = OperationType;
|
||||
use NativeOperation::*;
|
||||
match self {
|
||||
|
|
@ -178,7 +178,7 @@ impl Operation {
|
|||
/// The outer Result is error handling
|
||||
pub fn output_statement(&self) -> Result<Option<Statement>> {
|
||||
use Statement::*;
|
||||
let pred: Option<Predicate> = self.code().output_predicate();
|
||||
let pred: Option<Predicate> = self.predicate().output_predicate();
|
||||
|
||||
let st_args: Option<Vec<StatementArg>> = match self {
|
||||
Self::None => Some(vec![]),
|
||||
|
|
@ -404,7 +404,7 @@ impl Operation {
|
|||
impl fmt::Display for Operation {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln!(f, "middleware::Operation:")?;
|
||||
writeln!(f, " {:?} ", self.code())?;
|
||||
writeln!(f, " {:?} ", self.predicate())?;
|
||||
for arg in self.args().iter() {
|
||||
writeln!(f, " {}", arg)?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue