avm_interface/
lib.rs

1/*
2 * Copyright 2021 Fluence Labs Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#![forbid(unsafe_code)]
18#![warn(rust_2018_idioms)]
19#![deny(
20    dead_code,
21    nonstandard_style,
22    unused_imports,
23    unused_mut,
24    unused_variables,
25    unused_unsafe,
26    unreachable_patterns
27)]
28
29mod call_request_parameters;
30mod call_service_result;
31mod outcome;
32mod particle_parameters;
33pub mod raw_outcome;
34
35use air_interpreter_interface::CallArgumentsDeserializeError;
36use air_interpreter_interface::CallRequestsDeserializeError;
37use air_interpreter_interface::CallResultsSerializeError;
38use air_interpreter_interface::SerializedCallRequests;
39use air_interpreter_interface::TetrapletDeserializeError;
40use thiserror::Error as ThisError;
41
42#[derive(Debug, ThisError)]
43#[allow(clippy::enum_variant_names)]
44pub enum CallSeDeErrors {
45    /// Errors encountered while trying to serialize call results.
46    #[error("error occurred while call results `{call_results:?}` deserialization: {se_error}")]
47    CallResultsSeFailed {
48        call_results: air_interpreter_interface::CallResults,
49        se_error: CallResultsSerializeError,
50    },
51
52    /// This error is encountered when deserialization pof call requests failed for some reason.
53    #[error("'{raw_call_request:?}' can't been serialized with error '{error}'")]
54    CallRequestsDeError {
55        raw_call_request: SerializedCallRequests,
56        error: CallRequestsDeserializeError,
57    },
58
59    /// Errors encountered while trying to deserialize arguments from call parameters returned
60    /// by the interpreter. In the corresponding struct such arguments are Vec<JValue> serialized
61    /// to a string.
62    #[error("error occurred while deserialization of arguments from call params `{call_params:?}`: {de_error}")]
63    CallParamsArgsDeFailed {
64        call_params: air_interpreter_interface::CallRequestParams,
65        de_error: CallArgumentsDeserializeError,
66    },
67
68    /// Errors encountered while trying to deserialize tetraplets from call parameters returned
69    /// by the interpreter. In the corresponding struct such tetraplets are
70    /// Vec<Vec<SecurityTetraplet>> serialized to a string.
71    #[error("error occurred while deserialization of tetraplets from call params `{call_params:?}`: {de_error}")]
72    CallParamsTetrapletsDeFailed {
73        call_params: air_interpreter_interface::CallRequestParams,
74        de_error: TetrapletDeserializeError,
75    },
76}
77
78type JValue = serde_json::Value;
79
80pub use air_interpreter_interface::SoftLimitsTriggering;
81pub use call_request_parameters::*;
82pub use call_service_result::*;
83pub use outcome::*;
84pub use particle_parameters::*;