With a small amount of work we can extract Tolstoy's tx_processor, moving it into db and wrapping it in conn.rs.
The signature might look something like this:
impl<'a, 'c> InProgress<'a, 'c> {
/// Write out the contents of the store in a way that can be loaded.
/// There are two ways to do this:
///
/// - Preserving identifiers. Loading onto a non-empty store is likely to fail.
/// Loading into the existing store should transact nothing.
/// - Remapping all identifiers to temporary IDs. This is more work to load, and
/// repeated loads will result in some duplicated entities, but smushing should
/// cause identifiers to be unified.
///
/// The file will be populated with a sequence of transactions, each consisting of
/// a sequence of datoms.
fn export(&self, file: File) -> Result<File> {
…
}
}
impl<'a, 'c> InProgressRead<'a, 'c> {
fn export(&self, file: File) -> Result<File> {
self.inner.export(file)
}
}
impl Conn {
fn export(&self, file: File) -> Result<File> {
self.begin_read()?.export(file)
}
}
impl Store {
fn export(&self, file: File) -> Result<File> {
self.conn.export(file)
}
}
With a small amount of work we can extract Tolstoy's
tx_processor
, moving it intodb
and wrapping it inconn.rs
.The signature might look something like this:
That block comment is one way this could work.