Skip to content

Commit

Permalink
Rename MultipleParams DuplicateParams
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Jul 9, 2024
1 parent 3a4d192 commit 8b097ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions payjoin/src/uri/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct PjParseError(InternalPjParseError);
#[derive(Debug)]
pub(crate) enum InternalPjParseError {
BadPjOs,
MultipleParams(&'static str),
DuplicateParams(&'static str),
MissingEndpoint,
NotUtf8,
BadEndpoint,
Expand All @@ -24,7 +24,7 @@ impl std::fmt::Display for PjParseError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self.0 {
InternalPjParseError::BadPjOs => write!(f, "Bad pjos parameter"),
InternalPjParseError::MultipleParams(param) => {
InternalPjParseError::DuplicateParams(param) => {
write!(f, "Multiple instances of parameter '{}'", param)
}
InternalPjParseError::MissingEndpoint => write!(f, "Missing payjoin endpoint"),
Expand Down
6 changes: 3 additions & 3 deletions payjoin/src/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ impl<'a> bip21::de::DeserializationState<'a> for DeserializationState {
Ok(bip21::de::ParamKind::Known)
}
#[cfg(feature = "v2")]
"ohttp" => Err(InternalPjParseError::MultipleParams("ohttp").into()),
"ohttp" => Err(InternalPjParseError::DuplicateParams("ohttp").into()),
"pj" if self.pj.is_none() => {
let endpoint = Cow::try_from(value).map_err(|_| InternalPjParseError::NotUtf8)?;
let url = Url::parse(&endpoint).map_err(|_| InternalPjParseError::BadEndpoint)?;
self.pj = Some(url);

Ok(bip21::de::ParamKind::Known)
}
"pj" => Err(InternalPjParseError::MultipleParams("pj").into()),
"pj" => Err(InternalPjParseError::DuplicateParams("pj").into()),
"pjos" if self.pjos.is_none() => {
match &*Cow::try_from(value).map_err(|_| InternalPjParseError::BadPjOs)? {
"0" => self.pjos = Some(false),
Expand All @@ -261,7 +261,7 @@ impl<'a> bip21::de::DeserializationState<'a> for DeserializationState {
}
Ok(bip21::de::ParamKind::Known)
}
"pjos" => Err(InternalPjParseError::MultipleParams("pjos").into()),
"pjos" => Err(InternalPjParseError::DuplicateParams("pjos").into()),
_ => Ok(bip21::de::ParamKind::Unknown),
}
}
Expand Down

0 comments on commit 8b097ce

Please sign in to comment.