mirror of
https://github.com/ankitects/anki.git
synced 2025-11-10 22:57:11 -05:00
split the rust code into a workspace
This commit is contained in:
parent
f24a396c52
commit
249e2a2da0
7 changed files with 53 additions and 50 deletions
10
rs/Cargo.lock
generated
10
rs/Cargo.lock
generated
|
|
@ -12,9 +12,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ankirs"
|
name = "ankirs"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
|
||||||
"pyo3",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
|
|
@ -163,6 +160,13 @@ dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pybridge"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"pyo3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyo3"
|
name = "pyo3"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,6 @@
|
||||||
[package]
|
[workspace]
|
||||||
name = "ankirs"
|
members = ["ankirs", "pybridge"]
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2018"
|
|
||||||
authors = ["Ankitects Pty Ltd and contributors"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
|
|
||||||
|
|
||||||
[dependencies.pyo3]
|
|
||||||
version = "0.8.0"
|
|
||||||
features = ["extension-module"]
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "_ankirs"
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
|
||||||
5
rs/ankirs/Cargo.toml
Normal file
5
rs/ankirs/Cargo.toml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[package]
|
||||||
|
name = "ankirs"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
authors = ["Ankitects Pty Ltd and contributors"]
|
||||||
1
rs/ankirs/src/lib.rs
Normal file
1
rs/ankirs/src/lib.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
13
rs/pybridge/Cargo.toml
Normal file
13
rs/pybridge/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
[package]
|
||||||
|
name = "pybridge"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
authors = ["Ankitects Pty Ltd and contributors"]
|
||||||
|
|
||||||
|
[dependencies.pyo3]
|
||||||
|
version = "0.8.0"
|
||||||
|
features = ["extension-module"]
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "_ankirs"
|
||||||
|
crate-type = ["cdylib"]
|
||||||
25
rs/pybridge/src/lib.rs
Normal file
25
rs/pybridge/src/lib.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
use pyo3::exceptions;
|
||||||
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
#[pyclass]
|
||||||
|
struct Bridge {}
|
||||||
|
|
||||||
|
#[pymethods]
|
||||||
|
impl Bridge {
|
||||||
|
#[new]
|
||||||
|
fn init(obj: &PyRawObject) {
|
||||||
|
obj.init({ Bridge {} });
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cmd(&mut self, _request: String) -> PyResult<String> {
|
||||||
|
Ok("test".to_string())
|
||||||
|
.map_err(|e: std::io::Error| exceptions::Exception::py_err(format!("{:?}", e)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[pymodule]
|
||||||
|
fn _ankirs(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||||
|
m.add_class::<Bridge>()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
use pyo3::prelude::*;
|
|
||||||
use pyo3::exceptions;
|
|
||||||
|
|
||||||
#[pyclass]
|
|
||||||
struct Bridge {
|
|
||||||
}
|
|
||||||
|
|
||||||
#[pymethods]
|
|
||||||
impl Bridge {
|
|
||||||
|
|
||||||
#[new]
|
|
||||||
fn new(obj: &PyRawObject) {
|
|
||||||
obj.init({
|
|
||||||
Bridge { }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn cmd(&mut self, request: String) -> PyResult<String> {
|
|
||||||
Ok("test".to_string())
|
|
||||||
.map_err(|e: std::io::Error| {
|
|
||||||
exceptions::Exception::py_err(format!("{:?}", e))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[pymodule]
|
|
||||||
fn _ankirs(_py: Python, m: &PyModule) -> PyResult<()> {
|
|
||||||
m.add_class::<Bridge>()?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue