Make backend
This commit is contained in:
parent
59e9f1ca73
commit
4439e7cb47
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
/target
|
/target
|
||||||
/Cargo.lock
|
/Cargo.lock
|
||||||
|
/venv
|
||||||
|
|
|
@ -4,5 +4,9 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
[lib]
|
||||||
|
name = "wn_backend"
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
pyo3 = { version = "0.16.4", features = ["extension-module"] }
|
||||||
|
|
27
src/lib.rs
27
src/lib.rs
|
@ -1,8 +1,21 @@
|
||||||
#[cfg(test)]
|
use pyo3::prelude::*;
|
||||||
mod tests {
|
use std::process::Command;
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
#[pyfunction]
|
||||||
let result = 2 + 2;
|
fn send_notification(icon_path: &str, nick: &str, text: &str) -> PyResult<()> {
|
||||||
assert_eq!(result, 4);
|
Command::new("notify-send")
|
||||||
}
|
.arg("-i")
|
||||||
|
.arg(icon_path)
|
||||||
|
.arg(format!("{}:", nick))
|
||||||
|
.arg(text)
|
||||||
|
.spawn()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[pymodule]
|
||||||
|
fn wn_backend(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||||
|
m.add_function(wrap_pyfunction!(send_notification, m)?)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue