Skip to content

Commit 25cc42a

Browse files
authored
Rename EncapsulationError to DecapsulationError (#1601)
2 parents fec44af + 739123c commit 25cc42a

5 files changed

Lines changed: 32 additions & 32 deletions

File tree

payjoin-ffi/src/send/error.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ impl From<FfiValidationError> for SenderInputError {
6060
#[error(transparent)]
6161
pub struct CreateRequestError(#[from] send::v2::CreateRequestError);
6262

63-
/// Error returned for v2-specific payload encapsulation errors.
63+
/// Error returned for v2-specific payload decapsulation errors.
6464
#[derive(Debug, thiserror::Error, uniffi::Object)]
6565
#[uniffi::export(Debug, Display)]
6666
#[error(transparent)]
67-
pub struct EncapsulationError(#[from] send::v2::EncapsulationError);
67+
pub struct DecapsulationError(#[from] send::v2::DecapsulationError);
6868

6969
/// Error that may occur when the response from receiver is malformed.
7070
#[derive(Debug, thiserror::Error, uniffi::Object)]
@@ -126,9 +126,9 @@ pub struct SenderReplayError(
126126
#[derive(Debug, thiserror::Error, uniffi::Error)]
127127
#[error(transparent)]
128128
pub enum SenderPersistedError {
129-
/// rust-payjoin sender Encapsulation error
129+
/// rust-payjoin sender Decapsulation error
130130
#[error(transparent)]
131-
EncapsulationError(Arc<EncapsulationError>),
131+
DecapsulationError(Arc<DecapsulationError>),
132132
/// rust-payjoin sender response error
133133
#[error(transparent)]
134134
ResponseError(ResponseError),
@@ -147,20 +147,20 @@ impl From<ImplementationError> for SenderPersistedError {
147147
fn from(value: ImplementationError) -> Self { SenderPersistedError::Storage(Arc::new(value)) }
148148
}
149149

150-
impl<S> From<payjoin::persist::PersistedError<send::v2::EncapsulationError, S>>
150+
impl<S> From<payjoin::persist::PersistedError<send::v2::DecapsulationError, S>>
151151
for SenderPersistedError
152152
where
153153
S: std::error::Error + Send + Sync + 'static,
154154
{
155-
fn from(err: payjoin::persist::PersistedError<send::v2::EncapsulationError, S>) -> Self {
155+
fn from(err: payjoin::persist::PersistedError<send::v2::DecapsulationError, S>) -> Self {
156156
if err.storage_error_ref().is_some() {
157157
if let Some(storage_err) = err.storage_error() {
158158
return SenderPersistedError::from(ImplementationError::new(storage_err));
159159
}
160160
return SenderPersistedError::Unexpected;
161161
}
162162
if let Some(api_err) = err.api_error() {
163-
return SenderPersistedError::EncapsulationError(Arc::new(api_err.into()));
163+
return SenderPersistedError::DecapsulationError(Arc::new(api_err.into()));
164164
}
165165
SenderPersistedError::Unexpected
166166
}

payjoin-ffi/src/send/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::str::FromStr;
22
use std::sync::{Arc, RwLock};
33

44
pub use error::{
5-
BuildSenderError, CreateRequestError, EncapsulationError, PsbtParseError, ResponseError,
5+
BuildSenderError, CreateRequestError, DecapsulationError, PsbtParseError, ResponseError,
66
SenderInputError,
77
};
88

@@ -456,7 +456,7 @@ pub struct WithReplyKeyTransition(
456456
payjoin::persist::MaybeFatalTransition<
457457
payjoin::send::v2::SessionEvent,
458458
payjoin::send::v2::Sender<payjoin::send::v2::PollingForProposal>,
459-
payjoin::send::v2::EncapsulationError,
459+
payjoin::send::v2::DecapsulationError,
460460
>,
461461
>,
462462
>,

payjoin/src/core/send/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub(crate) enum InternalValidationError {
9898
ContentTooLarge,
9999
Proposal(InternalProposalError),
100100
#[cfg(feature = "v2")]
101-
V2Encapsulation(crate::send::v2::EncapsulationError),
101+
V2Decapsulation(crate::send::v2::DecapsulationError),
102102
}
103103

104104
impl From<InternalValidationError> for ValidationError {
@@ -126,7 +126,7 @@ impl fmt::Display for ValidationError {
126126
}
127127
Proposal(e) => write!(f, "proposal PSBT error: {e}"),
128128
#[cfg(feature = "v2")]
129-
V2Encapsulation(e) => write!(f, "v2 encapsulation error: {e}"),
129+
V2Decapsulation(e) => write!(f, "v2 encapsulation error: {e}"),
130130
}
131131
}
132132
}
@@ -141,7 +141,7 @@ impl std::error::Error for ValidationError {
141141
ContentTooLarge => None,
142142
Proposal(e) => Some(e),
143143
#[cfg(feature = "v2")]
144-
V2Encapsulation(e) => Some(e),
144+
V2Decapsulation(e) => Some(e),
145145
}
146146
}
147147
}

payjoin/src/core/send/v2/error.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ impl From<crate::into_url::Error> for CreateRequestError {
5555
}
5656
}
5757

58-
/// Error returned for v2-specific payload encapsulation errors.
58+
/// Error returned for v2-specific payload decapsulation errors.
5959
#[derive(Debug)]
60-
pub struct EncapsulationError(InternalEncapsulationError);
60+
pub struct DecapsulationError(InternalDecapsulationError);
6161

6262
#[derive(Debug)]
63-
pub(crate) enum InternalEncapsulationError {
63+
pub(crate) enum InternalDecapsulationError {
6464
/// The HPKE failed.
6565
Hpke(crate::hpke::HpkeError),
6666
/// The directory returned a bad response
6767
DirectoryResponse(DirectoryResponseError),
6868
}
6969

70-
impl fmt::Display for EncapsulationError {
70+
impl fmt::Display for DecapsulationError {
7171
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
72-
use InternalEncapsulationError::*;
72+
use InternalDecapsulationError::*;
7373

7474
match &self.0 {
7575
Hpke(error) => write!(f, "HPKE error: {error}"),
@@ -78,9 +78,9 @@ impl fmt::Display for EncapsulationError {
7878
}
7979
}
8080

81-
impl std::error::Error for EncapsulationError {
81+
impl std::error::Error for DecapsulationError {
8282
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
83-
use InternalEncapsulationError::*;
83+
use InternalDecapsulationError::*;
8484

8585
match &self.0 {
8686
Hpke(error) => Some(error),
@@ -89,12 +89,12 @@ impl std::error::Error for EncapsulationError {
8989
}
9090
}
9191

92-
impl From<InternalEncapsulationError> for EncapsulationError {
93-
fn from(value: InternalEncapsulationError) -> Self { EncapsulationError(value) }
92+
impl From<InternalDecapsulationError> for DecapsulationError {
93+
fn from(value: InternalDecapsulationError) -> Self { DecapsulationError(value) }
9494
}
9595

96-
impl From<InternalEncapsulationError> for super::ResponseError {
97-
fn from(value: InternalEncapsulationError) -> Self {
98-
super::InternalValidationError::V2Encapsulation(value.into()).into()
96+
impl From<InternalDecapsulationError> for super::ResponseError {
97+
fn from(value: InternalDecapsulationError) -> Self {
98+
super::InternalValidationError::V2Decapsulation(value.into()).into()
9999
}
100100
}

payjoin/src/core/send/v2/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
3131
use bitcoin::hashes::{sha256, Hash};
3232
use bitcoin::Address;
33-
pub use error::{CreateRequestError, EncapsulationError};
34-
use error::{InternalCreateRequestError, InternalEncapsulationError};
33+
pub use error::{CreateRequestError, DecapsulationError};
34+
use error::{InternalCreateRequestError, InternalDecapsulationError};
3535
use ohttp::ClientResponse;
3636
use serde::{Deserialize, Serialize};
3737
pub use session::{
@@ -392,18 +392,18 @@ impl Sender<WithReplyKey> {
392392
self,
393393
response: &[u8],
394394
post_ctx: ClientResponse,
395-
) -> MaybeFatalTransition<SessionEvent, Sender<PollingForProposal>, EncapsulationError> {
395+
) -> MaybeFatalTransition<SessionEvent, Sender<PollingForProposal>, DecapsulationError> {
396396
match process_post_res(response, post_ctx) {
397397
Ok(()) => {}
398398
Err(e) =>
399399
if e.is_fatal() {
400400
return MaybeFatalTransition::fatal(
401401
SessionEvent::Closed(SessionOutcome::Failure),
402-
InternalEncapsulationError::DirectoryResponse(e).into(),
402+
InternalDecapsulationError::DirectoryResponse(e).into(),
403403
);
404404
} else {
405405
return MaybeFatalTransition::transient(
406-
InternalEncapsulationError::DirectoryResponse(e).into(),
406+
InternalDecapsulationError::DirectoryResponse(e).into(),
407407
);
408408
},
409409
}
@@ -533,11 +533,11 @@ impl Sender<PollingForProposal> {
533533
if e.is_fatal() {
534534
return MaybeSuccessTransitionWithNoResults::fatal(
535535
SessionEvent::Closed(SessionOutcome::Failure),
536-
InternalEncapsulationError::DirectoryResponse(e).into(),
536+
InternalDecapsulationError::DirectoryResponse(e).into(),
537537
);
538538
} else {
539539
return MaybeSuccessTransitionWithNoResults::transient(
540-
InternalEncapsulationError::DirectoryResponse(e).into(),
540+
InternalDecapsulationError::DirectoryResponse(e).into(),
541541
);
542542
},
543543
};
@@ -551,7 +551,7 @@ impl Sender<PollingForProposal> {
551551
Err(e) =>
552552
return MaybeSuccessTransitionWithNoResults::fatal(
553553
SessionEvent::Closed(SessionOutcome::Failure),
554-
InternalEncapsulationError::Hpke(e).into(),
554+
InternalDecapsulationError::Hpke(e).into(),
555555
),
556556
};
557557

0 commit comments

Comments
 (0)