pub struct Mirror { /* private fields */ }Expand description
A database kept current from replication, and the directory of its node file and reverse index.
Implementations§
Source§impl Mirror
impl Mirror
Sourcepub fn new(url: impl Into<String>, dir: impl Into<PathBuf>) -> Self
pub fn new(url: impl Into<String>, dir: impl Into<PathBuf>) -> Self
A mirror in the database at url (postgresql://user@host/db, or host=… user=…), with its files in dir.
Connections are not encrypted.
Sourcepub fn import(
&self,
pbf: impl AsRef<Path>,
replication: Option<&Replication>,
opts: &ImportOpts,
) -> Result<ImportStats, SyncError>
pub fn import( &self, pbf: impl AsRef<Path>, replication: Option<&Replication>, opts: &ImportOpts, ) -> Result<ImportStats, SyncError>
Creates the osm schema from a PBF file, which must be sorted by type and ID as published files are, and makes
the node file and the reverse index in the directory, replacing any there.
The file’s replication sequence is the one ImportOpts::sequence or its header gives. replication, the
stream ImportOpts::replication_url or the header names, finds it from the file’s timestamp when neither
does, as for a planet file, and checks a sequence given in the options against that timestamp when the header
gives none for the stream.
Sourcepub fn update(
&self,
replication: &Replication,
opts: &UpdateOpts,
) -> Result<UpdateStats, SyncError>
pub fn update( &self, replication: &Replication, opts: &UpdateOpts, ) -> Result<UpdateStats, SyncError>
open, then OpenMirror::update: the diffs of replication after the database’s sequence.
Sourcepub fn open(&self) -> Result<OpenMirror, SyncError>
pub fn open(&self) -> Result<OpenMirror, SyncError>
Connects to the database and opens the reverse index, checked against the database and brought up to it if a
crash left it behind: an error if it is missing, or of another database or ahead of it, which
rebuild fixes. The node file is opened by the first update, and stays open with the index
until the mirror is dropped; only one process can have either open at a time.
Sourcepub fn rebuild(&self, from: &Rebuild<'_>) -> Result<RebuildStats, SyncError>
pub fn rebuild(&self, from: &Rebuild<'_>) -> Result<RebuildStats, SyncError>
Makes the node file and the reverse index again, up to the database’s revision. The database is only read.
Sourcepub fn state(&self) -> Result<DbState, SyncError>
pub fn state(&self) -> Result<DbState, SyncError>
The database’s position in its replication stream.
Sourcepub fn status(&self) -> Result<Status, SyncError>
pub fn status(&self) -> Result<Status, SyncError>
The database’s position, and its files’ stamps.
Sourcepub fn index_path(&self) -> PathBuf
pub fn index_path(&self) -> PathBuf
The reverse index.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Mirror
impl Freeze for Mirror
impl Move for Mirror
impl RefUnwindSafe for Mirror
impl Send for Mirror
impl Sync for Mirror
impl Unpin for Mirror
impl UnsafeUnpin for Mirror
impl UnwindSafe for Mirror
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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