diff --git a/examples/src/cli.rs b/examples/src/cli.rs index b690001..9d2f05e 100644 --- a/examples/src/cli.rs +++ b/examples/src/cli.rs @@ -459,10 +459,8 @@ async fn run() -> Result<(), Error> { None }; - if let Some((unknown_vid, mut payload)) = handle_message(message) { - let message = vid_database - .verify_and_open(&unknown_vid, &mut payload) - .await?; + if let Some((unknown_vid, payload)) = handle_message(message) { + let message = vid_database.verify_and_open(&unknown_vid, payload).await?; info!( "{vid} is verified and added to the database {}", diff --git a/tsp/src/async_store.rs b/tsp/src/async_store.rs index 7f83349..f17ecfd 100644 --- a/tsp/src/async_store.rs +++ b/tsp/src/async_store.rs @@ -401,16 +401,15 @@ impl AsyncStore { } /// Process the payload from a 'PendingMessage' by resolving the unknown vid and retrying - pub async fn verify_and_open<'a, T: AsRef<[u8]>>( + /// This takes a Vec as a payload; for a borrowing version the `as_inner()` version can be used; usually after + /// unpacking a TSP message you can't or need to do anything with it anyway. + pub async fn verify_and_open( &mut self, vid: &str, - payload: &'a mut [u8], - ) -> Result, Error> - where - &'a [u8]: Into, - { + mut payload: Vec, + ) -> Result { self.verify_vid(vid).await?; - Ok(self.inner.open_message(payload)?.map(|x| x.into())) + Ok(self.inner.open_message(&mut payload)?.into_owned()) } }