expose some interfaces for external usage (from introduction-pods) (#256)
* expose some interfaces for external usage (from introduction-pods) * add From<MainPod> for OperationArg, add copy op! Co-authored-by: Eduard S. <eduardsanou@posteo.net> --------- Co-authored-by: Eduard S. <eduardsanou@posteo.net>
This commit is contained in:
parent
5d13ac32ce
commit
7bc0bd08d2
6 changed files with 54 additions and 22 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use std::fmt;
|
||||
|
||||
use crate::{
|
||||
frontend::SignedPod,
|
||||
frontend::{MainPod, SignedPod},
|
||||
middleware::{AnchoredKey, OperationAux, OperationType, Statement, Value},
|
||||
};
|
||||
|
||||
|
|
@ -78,6 +78,18 @@ impl From<(&SignedPod, &str)> for OperationArg {
|
|||
))
|
||||
}
|
||||
}
|
||||
impl From<(&MainPod, &str)> for OperationArg {
|
||||
fn from((pod, key): (&MainPod, &str)) -> Self {
|
||||
// TODO: TryFrom.
|
||||
let value = pod
|
||||
.get(key)
|
||||
.unwrap_or_else(|| panic!("Key {} is not present in POD: {}", key, pod));
|
||||
Self::Statement(Statement::ValueOf(
|
||||
AnchoredKey::from((pod.id(), key)),
|
||||
value,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Statement> for OperationArg {
|
||||
fn from(s: Statement) -> Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue