pub struct CheckpointFile {
pub database_type: String,
pub checkpoint: Value,
pub phase: SyncPhase,
pub created_at: DateTime<Utc>,
}Expand description
Storage-agnostic checkpoint file wrapper.
This struct wraps database-specific checkpoints with metadata for storage and retrieval. The format is designed to be:
- Self-describing (includes
database_typefield) - Extensible (uses JSON Value for checkpoint data)
- Storage-agnostic (can be saved to local fs, remote storage, etc.)
§File Format
{
"database_type": "mongodb",
"checkpoint": {
"resume_token": [1, 2, 3],
"timestamp": "2024-01-01T00:00:00Z"
},
"phase": "FullSyncStart",
"created_at": "2024-01-01T00:00:00Z"
}Fields§
§database_type: StringDatabase type identifier (e.g., “mongodb”, “neo4j”)
checkpoint: ValueSerialized checkpoint data as JSON Value
phase: SyncPhaseSync phase when this checkpoint was created
created_at: DateTime<Utc>Timestamp when this checkpoint file was created
Implementations§
Source§impl CheckpointFile
impl CheckpointFile
Sourcepub fn new<C: Checkpoint>(checkpoint: &C, phase: SyncPhase) -> Result<Self>
pub fn new<C: Checkpoint>(checkpoint: &C, phase: SyncPhase) -> Result<Self>
Create new checkpoint file from database-specific checkpoint.
§Arguments
checkpoint- Database-specific checkpoint implementingCheckpointtraitphase- Sync phase (FullSyncStart, FullSyncEnd)
§Example
ⓘ
let checkpoint = MongoDBCheckpoint { ... };
let file = CheckpointFile::new(&checkpoint, SyncPhase::FullSyncStart)?;Sourcepub fn parse<C: Checkpoint>(&self) -> Result<C>
pub fn parse<C: Checkpoint>(&self) -> Result<C>
Parse checkpoint into database-specific type.
Validates that the stored database_type matches the expected type C.
§Errors
Returns an error if:
- The
database_typedoesn’t matchC::DATABASE_TYPE - The checkpoint data can’t be deserialized into type
C
§Example
ⓘ
let file: CheckpointFile = /* loaded from file */;
let checkpoint: MongoDBCheckpoint = file.parse()?;Sourcepub fn database_type(&self) -> &str
pub fn database_type(&self) -> &str
Get the database type of this checkpoint file.
Sourcepub fn created_at(&self) -> DateTime<Utc>
pub fn created_at(&self) -> DateTime<Utc>
Get the timestamp when this checkpoint file was created.
Trait Implementations§
Source§impl Clone for CheckpointFile
impl Clone for CheckpointFile
Source§fn clone(&self) -> CheckpointFile
fn clone(&self) -> CheckpointFile
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CheckpointFile
impl Debug for CheckpointFile
Source§impl<'de> Deserialize<'de> for CheckpointFile
impl<'de> Deserialize<'de> for CheckpointFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CheckpointFile
impl RefUnwindSafe for CheckpointFile
impl Send for CheckpointFile
impl Sync for CheckpointFile
impl Unpin for CheckpointFile
impl UnsafeUnpin for CheckpointFile
impl UnwindSafe for CheckpointFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more