diff --git a/indy_ledger_response_parser/src/domain/response.rs b/indy_ledger_response_parser/src/domain/response.rs index 1e1d42dadf..be291f50c2 100644 --- a/indy_ledger_response_parser/src/domain/response.rs +++ b/indy_ledger_response_parser/src/domain/response.rs @@ -21,7 +21,8 @@ impl Reply { pub fn result(self) -> T { match self { Reply::ReplyV0(reply) => reply.result, - Reply::ReplyV1(mut reply) => reply.data.result.remove(0).result, + // SAFETY: Empty array cannot be instantiated + Reply::ReplyV1(reply) => reply.data.result.into_iter().next().unwrap().result, } } } @@ -38,7 +39,7 @@ pub struct ReplyV1 { #[derive(Debug, Deserialize)] pub struct ReplyDataV1 { - pub result: Vec>, + pub result: [ReplyV0; 1], } #[derive(Debug, Deserialize)] @@ -124,14 +125,15 @@ where { type Error = IndyError; - fn try_from(mut value: ReplyV1>) -> Result { + fn try_from(value: ReplyV1>) -> Result { let value = value .data .result - .pop() + .into_iter() + .next() .ok_or_else(|| err_msg(IndyErrorKind::InvalidTransaction, "Invalid response type"))?; let data = ReplyDataV1 { - result: vec![value.try_into()?], + result: [value.try_into()?], }; Ok(ReplyV1 { data }) }