#![allow(unused_variables, unused_mut)]
fn main() {
#[cfg(any(feature = "linking", feature = "dynamic_loading"))]
example::run().unwrap();
#[cfg(not(any(feature = "linking", feature = "dynamic_loading")))]
println!(
"The Services API needs the native client (enable the linking or dynamic_loading feature)"
);
}
#[cfg(any(feature = "linking", feature = "dynamic_loading"))]
mod example {
use rsfbclient::services::{ServiceManager, SvcBackupOptions, SvcRestoreOptions};
use rsfbclient::FbError;
pub fn run() -> Result<(), FbError> {
#[cfg(feature = "linking")]
let mut svc = ServiceManager::builder()
.host("localhost")
.user("SYSDBA")
.pass("masterkey")
.attach()?;
#[cfg(all(feature = "dynamic_loading", not(feature = "linking")))]
let mut svc = ServiceManager::builder()
.host("localhost")
.user("SYSDBA")
.pass("masterkey")
.with_dyn_load("./fbclient.lib")
.attach()?;
println!("server version: {}", svc.server_version()?);
println!("backing up examples.fdb:");
svc.backup_with_output(
"examples.fdb",
"examples.fbk",
SvcBackupOptions::default(),
|line| println!(" {}", line),
)?;
let opts = SvcRestoreOptions {
replace: true,
..SvcRestoreOptions::default()
};
svc.restore("examples.fbk", "examples_restored.fdb", opts)?;
println!("restored examples.fbk -> examples_restored.fdb");
Ok(())
}
}