From 0dbeeec3d4733869859ba8a6edbc76bf893ba579 Mon Sep 17 00:00:00 2001 From: Chirantan Ekbote Date: Thu, 15 Dec 2022 19:41:26 +0900 Subject: [PATCH] sdk/rust: Add `Body::with_payload` Add the `Body::with_payload` method, which can be used to change the type of the payload for a `Body`. This is useful when parsing the payload needs to be deferred until after the body is parsed. --- sdk/rust/core/src/vaa.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sdk/rust/core/src/vaa.rs b/sdk/rust/core/src/vaa.rs index 4538c921a..7b48c3084 100644 --- a/sdk/rust/core/src/vaa.rs +++ b/sdk/rust/core/src/vaa.rs @@ -218,6 +218,21 @@ impl Header { } } +impl

Body

{ + /// Replace the payload of the body. Useful when parsing the payload needs to be delayed. + pub fn with_payload(self, p: U) -> Body { + Body { + timestamp: self.timestamp, + nonce: self.nonce, + emitter_chain: self.emitter_chain, + emitter_address: self.emitter_address, + sequence: self.sequence, + consistency_level: self.consistency_level, + payload: p, + } + } +} + impl Body

{ /// Body Digest Components. ///