mozilla/mentat

Implement exporting (and importing)

Open

#579 创建于 2018年3月3日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Rust (116 fork)github user discovery
A-clienhancementhelp wanted

仓库指标

Star
 (1,661 star)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南