Skip to content

Commit

Permalink
feat: bump pyO3 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
shpaker authored Jan 1, 2025
1 parent 67784ed commit 2cb74cc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
[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]
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]
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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::<XIDError>())?;
m.add("XIDError", py.get_type::<XIDError>())?;
m.add("__version__", PY_MODULE_VERSION)?;
Ok(())
}
6 changes: 3 additions & 3 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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]
Expand All @@ -52,7 +52,7 @@ impl XID {
fn time<'p>(&self, _py: Python<'p>) -> PyResult<Bound<'p, PyDateTime>> {
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]
Expand Down

0 comments on commit 2cb74cc

Please sign in to comment.