mozilla/mentat

Implement exporting (and importing)

Open

#579 aberto em 3 de mar. de 2018

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)Rust (116 forks)github user discovery
A-clienhancementhelp wanted

Métricas do repositório

Stars
 (1.661 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

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)
    }
}

That block comment is one way this could work.

Guia do colaborador