Compare commits

..

No commits in common. "0a6072c478c0bd1fa52a49ba7514040a5cceb759" and "e3ac4c60baed70fb74275ca75bc2e6e88d381701" have entirely different histories.

7 changed files with 10 additions and 31 deletions

View file

@ -10,7 +10,7 @@ default-members = [".", "members/libpt-core"]
[workspace.package] [workspace.package]
publish = true publish = true
version = "0.5.0" version = "0.4.3"
edition = "2021" edition = "2021"
authors = ["Christoph J. Scherr <software@cscherr.de>"] authors = ["Christoph J. Scherr <software@cscherr.de>"]
license = "MIT" license = "MIT"
@ -29,7 +29,7 @@ categories = [
anyhow = "1.0.79" anyhow = "1.0.79"
thiserror = "1.0.56" thiserror = "1.0.56"
libpt-core = { version = "0.4.0", path = "members/libpt-core" } libpt-core = { version = "0.4.0", path = "members/libpt-core" }
libpt-bintols = { version = "0.5.0", path = "members/libpt-bintols" } libpt-bintols = { version = "0.4.0", path = "members/libpt-bintols" }
libpt-log = { version = "0.4.2", path = "members/libpt-log" } libpt-log = { version = "0.4.2", path = "members/libpt-log" }
[package] [package]

View file

@ -1,7 +1,7 @@
[package] [package]
name = "libpt-bintols" name = "libpt-bintols"
publish.workspace = true publish.workspace = true
version = "0.5.0" version = "0.4.0"
edition.workspace = true edition.workspace = true
authors.workspace = true authors.workspace = true
license.workspace = true license.workspace = true

View file

@ -25,4 +25,4 @@ pub const YOBI: u128 = 2u128.pow(80);
// use libpt_core; // use libpt_core;
pub mod datalayout; pub mod datalayout;
pub mod display; pub mod display;
pub mod split; pub mod split_numbers;

View file

@ -3,7 +3,6 @@
//! Sometimes, you need a large integer in the form of many bytes, so split into [u8]. //! Sometimes, you need a large integer in the form of many bytes, so split into [u8].
//! Rust provides //! Rust provides
/// Split unsigned integers into a [Vec] of [u8]s /// Split unsigned integers into a [Vec] of [u8]s
/// ///
/// Say you have the [u32] 1717 (binary: `00000000 00000000 00000110 10110101 `). This number would /// Say you have the [u32] 1717 (binary: `00000000 00000000 00000110 10110101 `). This number would
@ -15,7 +14,7 @@
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # use libpt_bintols::split::*; /// # use libpt_bintols::split_numbers::*;
/// ///
/// let x: u32 = 1717; /// let x: u32 = 1717;
/// ///
@ -23,7 +22,7 @@
/// ``` /// ```
pub fn unsigned_to_vec<T>(num: T) -> Vec<u8> pub fn unsigned_to_vec<T>(num: T) -> Vec<u8>
where where
u128: std::convert::From<T> u128: std::convert::From<T>,
{ {
let mut num: u128 = num.into(); let mut num: u128 = num.into();
if num == 0 { if num == 0 {

View file

@ -1,4 +1,4 @@
use libpt_bintols::split::*; use libpt_bintols::split_numbers::*;
#[test] #[test]
fn split_u128() { fn split_u128() {

View file

@ -19,7 +19,7 @@ name = "libpt"
crate-type = ["cdylib", "rlib"] crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
libpt = { version = "0.5.0", path = "../.." } libpt = { version = "0.4.3", path = "../.." }
pyo3 = { version = "0.19.0", features = ["full"] } pyo3 = { version = "0.19.0", features = ["full"] }
anyhow.workspace = true anyhow.workspace = true

View file

@ -2,30 +2,11 @@ use pyo3::prelude::*;
use libpt::bintols as origin; use libpt::bintols as origin;
mod split {
use libpt::bintols::split as origin;
use pyo3::prelude::*;
#[pyfunction]
pub fn split_int(data: u128) -> Vec<u8> {
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 { mod display {
use libpt::bintols::display as origin;
use pyo3::prelude::*; use pyo3::prelude::*;
use libpt::bintols::display as origin;
#[pyfunction] #[pyfunction]
pub fn bytes_to_bin(data: &[u8]) -> String { pub fn bytes_to_bin(data: &[u8]) -> String {
origin::bytes_to_bin(data) origin::bytes_to_bin(data)
@ -69,7 +50,6 @@ pub fn submodule(py: Python, parent: &PyModule) -> PyResult<()> {
module.add("YOBI", origin::YOBI)?; module.add("YOBI", origin::YOBI)?;
display::submodule(py, module)?; display::submodule(py, module)?;
split::submodule(py, module)?;
parent.add_submodule(module)?; parent.add_submodule(module)?;
Ok(()) Ok(())