py.rs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. use std::{
  2. sync::{Arc, Mutex},
  3. thread,
  4. };
  5. use crate::{
  6. error::{Error, Result},
  7. plugin::{
  8. Category, Plugin, PluginEvent, PluginInstance, PluginInstancePtr, PluginMetadata, SemVer,
  9. SubCategory,
  10. },
  11. scene::{MethodResponseFn, SceneGraph, SceneGraphPtr, SceneNodeId, SceneNodeType},
  12. };
  13. pub struct PythonPlugin {
  14. scene_graph: SceneGraphPtr,
  15. }
  16. impl PythonPlugin {
  17. pub fn new(scene_graph: SceneGraphPtr, sourcecode: String) -> Self {
  18. Self { scene_graph }
  19. }
  20. }
  21. impl Plugin for PythonPlugin {
  22. fn metadata(&self) -> PluginMetadata {
  23. PluginMetadata {
  24. name: "myplugin".to_string(),
  25. title: "My Plugin - Very Good A++".to_string(),
  26. desc: "This is the best plugin ever made. You should use it.".to_string(),
  27. author: "Tyler Durden".to_string(),
  28. version: SemVer {
  29. major: 0,
  30. minor: 0,
  31. patch: 1,
  32. pre: "alpha".to_string(),
  33. build: "".to_string(),
  34. },
  35. cat: Category::Null,
  36. subcat: SubCategory::Null,
  37. }
  38. }
  39. fn start(&self) -> Result<PluginInstancePtr> {
  40. let mut inst = PythonPluginInstance { scene_graph: self.scene_graph.clone() };
  41. Ok(Arc::new(Mutex::new(Box::new(inst))))
  42. }
  43. }
  44. struct PythonPluginInstance {
  45. scene_graph: SceneGraphPtr,
  46. }
  47. impl PluginInstance for PythonPluginInstance {
  48. fn update(&mut self, event: PluginEvent) -> Result<()> {
  49. Ok(())
  50. }
  51. }