Skip to content

Convert from to try_from for Certificate and CertificateRecord #2651

@dlachaume

Description

@dlachaume

Why

The conversion between Certificate and CertificateRecord is fallible: conversions operations can fail (e.g. to_json_hex()).

Currently, these conversions are implemented using From with unwrap(). Switching to TryFrom makes failures explicit and allows for proper error propagation.

What

Update the conversions in mithril-aggregator/src/database/record/certificate.rs:

  • Change impl From<Certificate> for CertificateRecord to TryFrom
  • Change impl From<CertificateRecord> for Certificate to TryFrom

How

  • Replace From with TryFrom in both directions between Certificate and CertificateRecord
  • Update all usages to use try_into() and handle failures

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions