rust/hg-pyo3/src/revlog/mod.rs
author Georges Racinet <georges.racinet@cloudcrane.io>
Tue, 24 Dec 2024 18:56:32 +0100
changeset 52778 523ca3d225f5
parent 52775 264047bf4b9b
child 52780 42b219a1404a
permissions -rw-r--r--
rust-pyo3-revlog: config extraction functions We put this aside in a separate submodule to avoid cluttering the main `revlog` module. We use two helpers to extract items from the passed Python configuration: an extension trait for `PyDict` and a macro. As the macro uses `intern!`, it might make a small differences if lots of revlogs have to be opened. Also, using `conf` in namings instead of `py_config` in most cases, as the fact that this is Python configuration is obvious from the context (name of the module) and the types. This allows to let many item extractions fit into a single line.

// revlog.rs
//
// Copyright 2019-2020 Georges Racinet <georges.racinet@octobus.net>
//           2020-2024 Raphaël Gomès <raphael.gomes@octobus.net>
//           2024 Georges Racinet <georges.racinet@cloudcrane.io>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
use pyo3::prelude::*;

use crate::util::new_submodule;

mod config;

pub fn init_module<'py>(
    py: Python<'py>,
    package: &str,
) -> PyResult<Bound<'py, PyModule>> {
    let m = new_submodule(py, package, "revlog")?;
    Ok(m)
}