Skip to content

Commit f536789

Browse files
authored
refactor(iroh-base)!: No Result for creating new NodeTicket (#2771)
## 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.~~
1 parent 4d41a69 commit f536789

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

iroh-base/src/ticket/node.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ use crate::{
2525
/// used to round-trip the ticket to string.
2626
///
2727
/// [`NodeId`]: crate::key::NodeId
28+
/// [`Display`]: std::fmt::Display
29+
/// [`FromStr`]: std::str::FromStr
2830
#[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
2931
#[display("{}", Ticket::serialize(self))]
3032
pub struct NodeTicket {
@@ -62,8 +64,8 @@ impl FromStr for NodeTicket {
6264

6365
impl NodeTicket {
6466
/// Creates a new ticket.
65-
pub fn new(node: NodeAddr) -> Result<Self> {
66-
Ok(Self { node })
67+
pub fn new(node: NodeAddr) -> Self {
68+
Self { node }
6769
}
6870

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

0 commit comments

Comments
 (0)