pub struct NetworkRestore { /* private fields */ }Expand description
A network restore operation that copies database files from a peer node.
Manages the lifecycle of a restore: starting the transfer, tracking progress, and completing or failing.
Implementations§
Source§impl NetworkRestore
impl NetworkRestore
Sourcepub fn new(config: NetworkRestoreConfig) -> Self
pub fn new(config: NetworkRestoreConfig) -> Self
Create a new network restore with the given configuration.
Sourcepub fn with_local_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_local_dir(self, dir: impl Into<PathBuf>) -> Self
Set the local directory where restored .ndb files will be written.
If not set, the current working directory is used.
Sourcepub fn get_state(&self) -> RestoreState
pub fn get_state(&self) -> RestoreState
Get the current restore state.
Sourcepub fn get_progress(&self) -> RestoreProgress
pub fn get_progress(&self) -> RestoreProgress
Get a snapshot of the current progress.
Sourcepub fn get_config(&self) -> &NetworkRestoreConfig
pub fn get_config(&self) -> &NetworkRestoreConfig
Get the restore configuration.
Sourcepub fn execute(&self) -> Result<()>
pub fn execute(&self) -> Result<()>
Execute a full network restore: connect to the source node, transfer
all .ndb log files, and write them to the local log directory.
§Wire protocol (simple restore protocol)
Client → Server: [magic: u32 LE] (4 bytes) "NRST"
Server → Client: [file_count: u32 LE] (4 bytes)
For each file:
Server → Client: [name_len: u16 LE] (2 bytes)
[name: UTF-8 bytes] (name_len bytes)
[file_size: u64 LE] (8 bytes)
[data: file_size bytes]Sourcepub fn execute_via_dispatcher(&self) -> Result<()>
pub fn execute_via_dispatcher(&self) -> Result<()>
Execute a network restore against a peer’s RESTORE service
running on the TcpServiceDispatcher.
Closes findings F2 / F4 of the 2026 review.
execute() (above) connects raw TCP and writes RESTORE_MAGIC,
which works only against the standalone NetworkRestoreServer::start
path. Production replicated environments register the
NetworkRestoreServer as a ServiceHandler on the dispatcher;
the dispatcher first reads a length-prefixed service-name
handshake, then delegates to the handler. The handler reads
RESTORE_MAGIC over the channel framing (not raw stream bytes)
and replies with a single framed payload.
This method speaks that protocol: it goes through
connect_to_service(RESTORE), sends the magic over the channel,
then receives one framed payload containing the entire
[count][file_records...] structure and decodes it into local
files.
Sourcepub fn start(&self) -> Result<()>
pub fn start(&self) -> Result<()>
Mark the restore as in-progress.
State-transition helper that moves the restore from
RestoreState::NotStarted to RestoreState::InProgress and
updates the public progress snapshot to match. It performs no
I/O — the actual file transfer is driven by execute.
Callers that drive the restore via execute() do not need to
invoke this directly; execute() performs the same state
transition internally before any work begins.
Sourcepub fn update_progress(&self, bytes: u64, files: u32)
pub fn update_progress(&self, bytes: u64, files: u32)
Update the progress of an in-progress restore.
§Arguments
bytes- Total bytes transferred so far.files- Total files transferred so far.
Sourcepub fn update_elapsed(&self, elapsed: Duration)
pub fn update_elapsed(&self, elapsed: Duration)
Update the elapsed time for progress tracking.
Auto Trait Implementations§
impl !Freeze for NetworkRestore
impl !RefUnwindSafe for NetworkRestore
impl Send for NetworkRestore
impl Sync for NetworkRestore
impl Unpin for NetworkRestore
impl UnsafeUnpin for NetworkRestore
impl UnwindSafe for NetworkRestore
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more