diff --git a/Cargo.toml b/Cargo.toml index 0f74e5d..7f88788 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,12 @@ [package] name = "epyxid" -version = "0.3.2" +version = "0.3.3" edition = "2021" +description = "Python wrapper around the Rust implementation of xid" +license = "MIT" +repository = "https://github.com/als/epyxid" +documentation = "https://docs.rs/epyxid" +homepage = "https://github.com/als/epyxid" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] @@ -9,7 +14,7 @@ name = "epyxid" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.22.6", features = ["extension-module"] } +pyo3 = { version = "0.23.3", features = ["extension-module"] } xid = "1.1.1" [profile.release] diff --git a/README.md b/README.md index 39b4f40..7c8267f 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,16 @@ from epyxid import XID # Create a new XID xid = XID() +# Create an XID from a string +xid_str = XID.from_string("cnisffq7qo0qnbtbu5gg") +print(f"XID from string: {xid_str}") + +# Create an XID from bytes +xid_bytes = XID.from_bytes(b'e\xe5\xc7\xbfG\xd6\x01\xab\xaf\xab\xf1a') +print(f"XID from bytes: {xid_bytes}") + # Print the XID as a string -print(f"XID: {xid}") +print(f"XID: {str(xid)}") # Example output: XID: cnisffq7qo0qnbtbu5gg # Get the byte representation of the XID diff --git a/pyproject.toml b/pyproject.toml index 635efbe..a9b30b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ requires-python = ">=3.8" authors = [ {name = "Aleksandr Shpak", email = "shpaker@gmail.com"}, ] -version = "0.3.2" +version = "0.3.3" readme = "README.md" license = { file = "LICENSE.txt" } keywords = [ diff --git a/src/lib.rs b/src/lib.rs index c5ee560..bfdf61c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ use crate::errors::XIDError; use crate::utils::{xid_create, xid_from_bytes, xid_from_str}; use crate::wrapper::XID; -const PY_MODULE_VERSION: &str = "0.3.2"; +const PY_MODULE_VERSION: &str = "0.3.3"; mod errors; mod utils; @@ -20,7 +20,7 @@ fn epyxid(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(xid_create, m)?)?; m.add_function(wrap_pyfunction!(xid_from_str, m)?)?; m.add_function(wrap_pyfunction!(xid_from_bytes, m)?)?; - m.add("XIDError", py.get_type_bound::())?; + m.add("XIDError", py.get_type::())?; m.add("__version__", PY_MODULE_VERSION)?; Ok(()) } diff --git a/src/wrapper.rs b/src/wrapper.rs index 31b331b..04b9630 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -31,7 +31,7 @@ impl XID { } fn as_bytes<'p>(&self, _py: Python<'p>) -> Bound<'p, PyBytes> { - PyBytes::new_bound(_py, self.0.as_bytes()) + PyBytes::new(_py, self.0.as_bytes()) } fn to_str(&self) -> String { @@ -40,7 +40,7 @@ impl XID { #[getter] fn machine<'p>(&self, _py: Python<'p>) -> Bound<'p, PyBytes> { - PyBytes::new_bound(_py, &self.0.machine()) + PyBytes::new(_py, &self.0.machine()) } #[getter] @@ -52,7 +52,7 @@ impl XID { fn time<'p>(&self, _py: Python<'p>) -> PyResult> { let raw = self.0.as_bytes(); let unix_ts = u32::from_be_bytes([raw[0], raw[1], raw[2], raw[3]]); - PyDateTime::from_timestamp_bound(_py, unix_ts as f64, None) + PyDateTime::from_timestamp(_py, unix_ts as f64, None) } #[getter]