Skip to content

Commit 3b157b0

Browse files
committed
Remove deprecated Persister trait
This trait has been replaced by the new `SessionPersister`.
1 parent de94e66 commit 3b157b0

File tree

2 files changed

+1
-63
lines changed

2 files changed

+1
-63
lines changed

payjoin-ffi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub mod send;
1212
pub mod test_utils;
1313
pub mod uri;
1414

15-
pub use payjoin::persist::{NoopPersister, NoopSessionPersister};
15+
pub use payjoin::persist::{NoopSessionPersister};
1616

1717
pub use crate::bitcoin_ffi::*;
1818
pub use crate::ohttp::*;

payjoin/src/persist.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,3 @@
1-
use std::fmt::Display;
2-
3-
/// Types that can generate their own keys for persistent storage
4-
pub trait Value: serde::Serialize + serde::de::DeserializeOwned + Sized + Clone {
5-
type Key: AsRef<[u8]> + Clone + Display;
6-
7-
/// Unique identifier for this persisted value
8-
fn key(&self) -> Self::Key;
9-
}
10-
11-
/// Implemented types that should be persisted by the application.
12-
pub trait Persister<V: Value> {
13-
type Token: From<V>;
14-
type Error: std::error::Error + Send + Sync + 'static;
15-
16-
fn save(&mut self, value: V) -> Result<Self::Token, Self::Error>;
17-
fn load(&self, token: Self::Token) -> Result<V, Self::Error>;
18-
}
19-
20-
/// A key type that stores the value itself for no-op persistence
21-
#[derive(Debug, Clone, serde::Serialize)]
22-
pub struct NoopToken<V: Value>(V);
23-
24-
impl<V: Value> AsRef<[u8]> for NoopToken<V> {
25-
fn as_ref(&self) -> &[u8] {
26-
// Since this is a no-op implementation, we can return an empty slice
27-
// as we never actually need to use the bytes
28-
&[]
29-
}
30-
}
31-
32-
impl<'de, V: Value> serde::Deserialize<'de> for NoopToken<V> {
33-
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
34-
where
35-
D: serde::Deserializer<'de>,
36-
{
37-
Ok(NoopToken(V::deserialize(deserializer)?))
38-
}
39-
}
40-
41-
impl<V: Value> Value for NoopToken<V> {
42-
type Key = V::Key;
43-
44-
fn key(&self) -> Self::Key { self.0.key() }
45-
}
46-
47-
/// A persister that does nothing but store values in memory
48-
#[derive(Debug, Clone)]
49-
pub struct NoopPersister;
50-
51-
impl<V: Value> From<V> for NoopToken<V> {
52-
fn from(value: V) -> Self { NoopToken(value) }
53-
}
54-
impl<V: Value> Persister<V> for NoopPersister {
55-
type Token = NoopToken<V>;
56-
type Error = std::convert::Infallible;
57-
58-
fn save(&mut self, value: V) -> Result<Self::Token, Self::Error> { Ok(NoopToken(value)) }
59-
60-
fn load(&self, token: Self::Token) -> Result<V, Self::Error> { Ok(token.0) }
61-
}
62-
631
/// Handles cases where the transition either succeeds with a final result that ends the session, or hits a static condition and stays in the same state.
642
/// State transition may also be a fatal error or transient error.
653
pub struct MaybeSuccessTransitionWithNoResults<Event, SuccessValue, CurrentState, Err>(

0 commit comments

Comments
 (0)