54 lines
1.7 KiB
Rust
Raw Normal View History

2020-10-15 17:31:56 +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.
*/
2020-10-16 12:47:46 +03:00
use super::CallEvidencePath;
2020-10-15 17:31:56 +03:00
use serde::Deserialize;
use serde::Serialize;
2020-10-30 20:29:05 +03:00
use std::fmt::Display;
use std::fmt::Formatter;
2020-10-15 17:31:56 +03:00
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub(crate) struct CallEvidenceCtx {
2020-10-16 12:47:46 +03:00
pub(crate) current_path: CallEvidencePath,
pub(crate) current_subtree_elements_count: usize,
// TODO: consider change it to Vec for optimization
pub(crate) new_path: CallEvidencePath,
2020-10-15 17:31:56 +03:00
}
impl CallEvidenceCtx {
2020-10-16 12:47:46 +03:00
pub fn new(current_path: CallEvidencePath) -> Self {
let current_subtree_elements_count = current_path.len();
2020-10-15 17:31:56 +03:00
Self {
2020-10-16 12:47:46 +03:00
current_path,
current_subtree_elements_count,
new_path: CallEvidencePath::new(),
2020-10-15 17:31:56 +03:00
}
}
}
2020-10-30 20:29:05 +03:00
impl Display for CallEvidenceCtx {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
writeln!(f, "current path:\n{:?}", self.current_path)?;
writeln!(
f,
"current subtree elements count:\n{:?}",
self.current_subtree_elements_count
)?;
writeln!(f, "new path:\n{:?}", self.new_path)
}
}