|
@@ -309,11 +309,6 @@ impl PaymentRequestPayload {
|
|
|
Ok(Arc::new(PaymentRequestPayload { inner }))
|
|
Ok(Arc::new(PaymentRequestPayload { inner }))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /// Encode PaymentRequestPayload to JSON string
|
|
|
|
|
- pub fn to_string(&self) -> Result<String, FfiError> {
|
|
|
|
|
- Ok(serde_json::to_string(&self.inner)?)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/// Get the ID
|
|
/// Get the ID
|
|
|
pub fn id(&self) -> Option<String> {
|
|
pub fn id(&self) -> Option<String> {
|
|
|
self.inner.id.clone()
|
|
self.inner.id.clone()
|
|
@@ -340,6 +335,16 @@ impl PaymentRequestPayload {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+impl std::fmt::Display for PaymentRequestPayload {
|
|
|
|
|
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
|
+ write!(
|
|
|
|
|
+ f,
|
|
|
|
|
+ "{}",
|
|
|
|
|
+ serde_json::to_string(&self.inner).map_err(|_| std::fmt::Error)?
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
#[cfg(test)]
|
|
#[cfg(test)]
|
|
|
mod tests {
|
|
mod tests {
|
|
|
use super::*;
|
|
use super::*;
|
|
@@ -385,7 +390,7 @@ mod tests {
|
|
|
|
|
|
|
|
let payload = PaymentRequestPayload { inner };
|
|
let payload = PaymentRequestPayload { inner };
|
|
|
|
|
|
|
|
- let json = payload.to_string().unwrap();
|
|
|
|
|
|
|
+ let json = payload.to_string();
|
|
|
let decoded = PaymentRequestPayload::from_string(json).unwrap();
|
|
let decoded = PaymentRequestPayload::from_string(json).unwrap();
|
|
|
|
|
|
|
|
assert_eq!(decoded.id(), payload.id());
|
|
assert_eq!(decoded.id(), payload.id());
|