use trust_tasks_rs::{TransportContext, TransportHandler};
pub const BINDING_URI: &str = "https://trusttasks.org/binding/didcomm/0.1";
#[derive(Debug, Clone)]
pub struct DidcommHandler {
local: Option<String>,
peer: Option<String>,
}
impl DidcommHandler {
pub fn new(local: impl Into<Option<String>>, peer: impl Into<Option<String>>) -> Self {
Self {
local: local.into(),
peer: peer.into(),
}
}
pub fn local(&self) -> Option<&str> {
self.local.as_deref()
}
pub fn peer(&self) -> Option<&str> {
self.peer.as_deref()
}
}
impl TransportHandler for DidcommHandler {
fn binding_uri(&self) -> &str {
BINDING_URI
}
fn derive_parties(&self) -> TransportContext {
TransportContext {
issuer: self.peer.clone(),
recipient: self.local.clone(),
}
}
}