You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
788 B

  1. use pyo3::prelude::*;
  2. pub mod push;
  3. /// Returns the hash of all the rust source files at the time it was compiled.
  4. ///
  5. /// Used by python to detect if the rust library is outdated.
  6. #[pyfunction]
  7. fn get_rust_file_digest() -> &'static str {
  8. env!("SYNAPSE_RUST_DIGEST")
  9. }
  10. /// Formats the sum of two numbers as string.
  11. #[pyfunction]
  12. #[pyo3(text_signature = "(a, b, /)")]
  13. fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
  14. Ok((a + b).to_string())
  15. }
  16. /// The entry point for defining the Python module.
  17. #[pymodule]
  18. fn synapse_rust(py: Python<'_>, m: &PyModule) -> PyResult<()> {
  19. pyo3_log::init();
  20. m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
  21. m.add_function(wrap_pyfunction!(get_rust_file_digest, m)?)?;
  22. push::register_module(py, m)?;
  23. Ok(())
  24. }