Skip to content

Commit 70bb8c1

Browse files
committed
Change: rename Transition to BeforeAfter; deprecate Transition
1 parent 19db303 commit 70bb8c1

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/impls/level.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ use std::ops::RangeBounds;
2525
use futures_util::StreamExt;
2626
use log::warn;
2727

28+
use crate::BeforeAfter;
2829
use crate::KVResultStream;
2930
use crate::MapApi;
3031
use crate::MapApiRO;
3132
use crate::MapKey;
3233
use crate::Marked;
3334
use crate::MarkedOf;
34-
use crate::Transition;
3535

3636
/// A simple in-memory implementation of the Map API using a BTreeMap.
3737
///
@@ -129,7 +129,7 @@ where M: Clone + Unpin + Send + Sync + 'static
129129
&mut self,
130130
key: String,
131131
value: Option<(<String as MapKey<M>>::V, Option<M>)>,
132-
) -> Result<Transition<MarkedOf<String, M>>, io::Error> {
132+
) -> Result<BeforeAfter<MarkedOf<String, M>>, io::Error> {
133133
// The chance it is the bottom level is very low in a loaded system.
134134
// Thus, we always tombstone the key if it is None.
135135

src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,17 @@ pub use crate::map_key::MapKey;
8484
pub use crate::map_value::MapValue;
8585
pub use crate::marked::Marked;
8686

87+
#[deprecated(since = "0.2.0", note = "Use `BeforeAfter` instead")]
88+
pub type Transition<T> = BeforeAfter<T>;
89+
8790
/// Represents a transition from one state to another.
88-
/// The tuple contains the initial state and the resulting state.
89-
pub type Transition<T> = (T, T);
91+
///
92+
/// This type is a tuple containing two elements:
93+
/// - The first element represents the state before the transition (initial state)
94+
/// - The second element represents the state after the transition (resulting state)
95+
///
96+
/// It's commonly used to track changes in values or system states.
97+
pub type BeforeAfter<T> = (T, T);
9098

9199
/// A boxed stream that yields `Result` of key-value pairs or an `io::Error`.
92100
/// The stream is 'static to ensure it can live for the entire duration of the program.

src/map_api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::io;
2222

2323
use crate::map_api_ro::MapApiRO;
2424
use crate::map_key::MapKey;
25-
use crate::Transition;
25+
use crate::BeforeAfter;
2626

2727
/// Provides a read-write key-value map API, used to access state machine data.
2828
///
@@ -80,7 +80,7 @@ where
8080
///
8181
/// # Returns
8282
///
83-
/// A [`Transition`] containing:
83+
/// A [`BeforeAfter`] containing:
8484
/// - The old value (before the operation)
8585
/// - The new value (after the operation)
8686
///
@@ -92,5 +92,5 @@ where
9292
&mut self,
9393
key: K,
9494
value: Option<(K::V, Option<M>)>,
95-
) -> Result<Transition<crate::MarkedOf<K, M>>, io::Error>;
95+
) -> Result<BeforeAfter<crate::MarkedOf<K, M>>, io::Error>;
9696
}

0 commit comments

Comments
 (0)