94 lines
2.5 KiB
Rust
Raw Normal View History

2020-10-30 20:29:05 +03:00
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#![allow(improper_ctypes)]
#![warn(rust_2018_idioms)]
#![deny(
dead_code,
nonstandard_style,
unused_imports,
unused_mut,
unused_variables,
unused_unsafe,
unreachable_patterns
)]
mod air;
mod build_targets;
mod call_evidence;
mod errors;
mod execution;
pub mod log_targets;
pub use crate::call_evidence::CallEvidencePath;
pub use crate::call_evidence::CallResult;
pub use crate::call_evidence::EvidenceState;
pub use crate::errors::AquamarineError;
pub use air_parser::ast::Instruction;
2020-10-30 20:29:05 +03:00
pub use execution::execute_aqua;
pub use execution::parse;
2020-10-30 20:29:05 +03:00
2020-12-22 21:05:04 +03:00
pub use polyplets::ResolvedTriplet;
pub use polyplets::SecurityTetraplet;
2020-10-30 20:29:05 +03:00
pub(crate) type Result<T> = std::result::Result<T, AquamarineError>;
pub(crate) type JValue = serde_json::Value;
pub(crate) use build_targets::call_service;
pub(crate) use build_targets::get_current_peer_id;
2020-12-22 21:05:04 +03:00
use serde::Deserialize;
use serde::Serialize;
2020-10-30 20:29:05 +03:00
use std::cell::RefCell;
use std::fmt::Display;
use std::fmt::Formatter;
use std::rc::Rc;
2020-12-22 21:05:04 +03:00
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct ResolvedCallResult {
pub result: Rc<JValue>,
pub triplet: Rc<ResolvedTriplet>,
}
2020-11-03 17:43:58 +03:00
pub(crate) enum AValue<'i> {
2020-12-22 21:05:04 +03:00
JValueRef(ResolvedCallResult),
JValueAccumulatorRef(RefCell<Vec<ResolvedCallResult>>),
2020-11-03 17:43:58 +03:00
JValueFoldCursor(crate::air::FoldState<'i>),
2020-10-30 20:29:05 +03:00
}
2020-12-22 21:05:04 +03:00
pub(crate) trait JValuable {}
2020-11-03 17:43:58 +03:00
impl<'i> Display for AValue<'i> {
2020-10-30 20:29:05 +03:00
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
AValue::JValueRef(value) => write!(f, "{:?}", value)?,
AValue::JValueAccumulatorRef(acc) => {
write!(f, "[ ")?;
for value in acc.borrow().iter() {
write!(f, "{:?} ", value)?;
}
write!(f, "]")?;
}
2020-12-22 21:05:04 +03:00
AValue::JValueFoldCursor(_) => {
write!(f, "cursor")?;
2020-10-30 20:29:05 +03:00
}
}
Ok(())
}
}