Skip to content

Commit

Permalink
sdk/rust: Add Body::with_payload
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jynnantonix committed Dec 19, 2022
1 parent 4ea369d commit 0dbeeec
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sdk/rust/core/src/vaa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,21 @@ impl Header {
}
}

impl<P> Body<P> {
/// Replace the payload of the body. Useful when parsing the payload needs to be delayed.
pub fn with_payload<U>(self, p: U) -> Body<U> {
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<P: Serialize> Body<P> {
/// Body Digest Components.
///
Expand Down

0 comments on commit 0dbeeec

Please sign in to comment.