From 0a6072c478c0bd1fa52a49ba7514040a5cceb759 Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sun, 12 May 2024 17:58:55 +0200 Subject: [PATCH] feat: add bintols split to libpt-py --- members/libpt-py/src/bintols/mod.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/members/libpt-py/src/bintols/mod.rs b/members/libpt-py/src/bintols/mod.rs index ea0403f..72f19be 100644 --- a/members/libpt-py/src/bintols/mod.rs +++ b/members/libpt-py/src/bintols/mod.rs @@ -2,10 +2,29 @@ use pyo3::prelude::*; use libpt::bintols as origin; -mod display { +mod split { + use libpt::bintols::split as origin; use pyo3::prelude::*; + #[pyfunction] + pub fn split_int(data: u128) -> Vec { + origin::unsigned_to_vec(data) + } + + /// implement a python module in Rust + pub fn submodule(py: Python, parent: &PyModule) -> PyResult<()> { + let module = PyModule::new(py, "split")?; + + module.add_function(wrap_pyfunction!(split_int, module)?)?; + + parent.add_submodule(module)?; + Ok(()) + } +} + +mod display { use libpt::bintols::display as origin; + use pyo3::prelude::*; #[pyfunction] pub fn bytes_to_bin(data: &[u8]) -> String { @@ -50,6 +69,7 @@ pub fn submodule(py: Python, parent: &PyModule) -> PyResult<()> { module.add("YOBI", origin::YOBI)?; display::submodule(py, module)?; + split::submodule(py, module)?; parent.add_submodule(module)?; Ok(())