Skip to content

Commit

Permalink
refactor(iroh-base)!: No Result for creating new NodeTicket (#2771)
Browse files Browse the repository at this point in the history
## Description

There is no need for this to have a Result.  Also there's a From impl
anyway.  So clean this up.

## Breaking Changes

`NodeTicket::new` no longer returns `Result` but always succeeds (as
it already did).  This matches it's `From<NodeAddr>` impl which also
never fails.

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
- ~~[ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.~~
- ~~[ ] Tests if relevant.~~
- ~~[ ] All breaking changes documented.~~
  • Loading branch information
flub authored Oct 1, 2024
1 parent 4d41a69 commit f536789
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions iroh-base/src/ticket/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use crate::{
/// used to round-trip the ticket to string.
///
/// [`NodeId`]: crate::key::NodeId
/// [`Display`]: std::fmt::Display
/// [`FromStr`]: std::str::FromStr
#[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
#[display("{}", Ticket::serialize(self))]
pub struct NodeTicket {
Expand Down Expand Up @@ -62,8 +64,8 @@ impl FromStr for NodeTicket {

impl NodeTicket {
/// Creates a new ticket.
pub fn new(node: NodeAddr) -> Result<Self> {
Ok(Self { node })
pub fn new(node: NodeAddr) -> Self {
Self { node }
}

/// The [`NodeAddr`] of the provider for this ticket.
Expand Down Expand Up @@ -104,7 +106,7 @@ impl<'de> Deserialize<'de> for NodeTicket {
Self::from_str(&s).map_err(serde::de::Error::custom)
} else {
let peer = Deserialize::deserialize(deserializer)?;
Self::new(peer).map_err(serde::de::Error::custom)
Ok(Self::new(peer))
}
}
}
Expand Down

0 comments on commit f536789

Please sign in to comment.