use std::collections::HashMap;
#[cfg(feature = "python")]
use pyo3::prelude::*;
use crate::proto::plugin::ScoreReport;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(
feature = "python",
pyclass(name = "ResidueRef", module = "foldit_plugin_sdk", from_py_object)
)]
pub struct ResidueRef {
pub entity_id: molex::EntityId,
pub residue_index: u32,
}
#[cfg(feature = "python")]
#[pymethods]
impl ResidueRef {
#[new]
#[must_use]
pub fn new(entity_id: u32, residue_index: u32) -> Self {
Self {
entity_id: molex::EntityId::from_raw(entity_id),
residue_index,
}
}
#[must_use]
#[getter]
pub fn entity_id(&self) -> u32 {
self.entity_id.raw()
}
#[must_use]
#[getter]
pub fn residue_index(&self) -> u32 {
self.residue_index
}
}
#[derive(Debug, Clone, Default)]
#[cfg_attr(
feature = "python",
pyclass(name = "DispatchContext", module = "foldit_plugin_sdk", from_py_object)
)]
pub struct DispatchContext {
pub focused_entity_id: Option<molex::EntityId>,
pub selection: Vec<ResidueRef>,
pub designable: Vec<ResidueRef>,
}
#[cfg(feature = "python")]
#[pymethods]
impl DispatchContext {
#[new]
#[pyo3(signature = (focused_entity_id = None, selection = vec![], designable = vec![]))]
#[must_use]
pub fn new(
focused_entity_id: Option<u32>,
selection: Vec<ResidueRef>,
designable: Vec<ResidueRef>,
) -> Self {
Self {
focused_entity_id: focused_entity_id.map(molex::EntityId::from_raw),
selection,
designable,
}
}
#[must_use]
#[getter]
pub fn focused_entity_id(&self) -> Option<u32> {
self.focused_entity_id.map(molex::EntityId::raw)
}
#[must_use]
#[getter]
pub fn selection(&self) -> Vec<ResidueRef> {
self.selection.clone()
}
#[must_use]
#[getter]
pub fn designable(&self) -> Vec<ResidueRef> {
self.designable.clone()
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum ParamValue {
Int(i32),
Float(f32),
Bool(bool),
String(String),
Vec3([f32; 3]),
}
#[derive(Debug, Clone)]
pub enum PollOutcome {
Pending {
latest_assembly: Option<Vec<u8>>,
progress: Option<f32>,
stage: Option<String>,
score: Option<ScoreReport>,
},
Checkpoint {
latest_assembly: Option<Vec<u8>>,
progress: Option<f32>,
stage: Option<String>,
score: Option<ScoreReport>,
},
Cancelled {
assembly: Vec<u8>,
score: Option<ScoreReport>,
},
Final {
assembly: Vec<u8>,
score: Option<ScoreReport>,
},
Error {
code: String,
message: String,
details: HashMap<String, String>,
},
}