File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 11from typing import Final
2- from .lstore import hello_from_rust
2+ from .lstore import hello_from_rust , Database
33
4+ print (Database .ping ())
45
56msg = hello_from_rust ()
67assert "Rust" in msg
Original file line number Diff line number Diff line change @@ -50,6 +50,20 @@ pub fn get_physical_block_size(drive: &str) -> i16 {
5050 read_block_size ( drive, "physical" )
5151}
5252
53+ #[ pyclass]
54+ struct Database {
55+ #[ pyo3( get, set) ]
56+ page_size : usize ,
57+ }
58+
59+ #[ pymethods]
60+ impl Database {
61+ #[ staticmethod]
62+ fn ping ( ) -> String {
63+ return String :: from ( "pong!" ) ;
64+ }
65+ }
66+
5367/// Blazingly fast hello
5468#[ pyfunction]
5569fn hello_from_rust ( ) -> PyResult < String > {
@@ -59,6 +73,7 @@ fn hello_from_rust() -> PyResult<String> {
5973/// A Python module implemented in Rust.
6074#[ pymodule]
6175fn lstore ( m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
76+ m. add_class :: < Database > ( ) ?;
6277 m. add_function ( wrap_pyfunction ! ( hello_from_rust, m) ?) ?;
6378 Ok ( ( ) )
6479}
You can’t perform that action at this time.
0 commit comments