From dfa695f303f3994486d4a4aecc688288a353b6bd Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Fri, 24 Nov 2023 14:09:53 +0100 Subject: [PATCH] TryFrom to From --- sdk/src/types/block/output/metadata.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sdk/src/types/block/output/metadata.rs b/sdk/src/types/block/output/metadata.rs index 41fff2abee..4bee1b8907 100644 --- a/sdk/src/types/block/output/metadata.rs +++ b/sdk/src/types/block/output/metadata.rs @@ -120,11 +120,9 @@ mod dto { latest_commitment_id: SlotCommitmentId, } - impl TryFrom for OutputMetadata { - type Error = crate::types::block::Error; - - fn try_from(value: OutputMetadataDto) -> Result { - Ok(Self { + impl From for OutputMetadata { + fn from(value: OutputMetadataDto) -> Self { + Self { block_id: value.block_id, output_id: OutputId::new(value.transaction_id, value.output_index), is_spent: value.is_spent, @@ -132,7 +130,7 @@ mod dto { transaction_id_spent: value.transaction_id_spent, included_commitment_id: value.included_commitment_id, latest_commitment_id: value.latest_commitment_id, - }) + } } } @@ -153,7 +151,7 @@ mod dto { impl<'de> Deserialize<'de> for OutputMetadata { fn deserialize>(d: D) -> Result { - OutputMetadataDto::deserialize(d).and_then(|dto| dto.try_into().map_err(serde::de::Error::custom)) + Ok(OutputMetadataDto::deserialize(d)?.into()) } }