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:
arnaucube 2025-06-05 11:37:43 +02:00 committed by GitHub
parent 5d13ac32ce
commit 7bc0bd08d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 54 additions and 22 deletions

View file

@ -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 {