1use pyo3::prelude::*;
2use akinator_rs::models::Guess as GuessModel;
3
4
5#[pyclass]
8#[derive(Debug, Clone)]
9pub struct Guess(
10 pub GuessModel,
11);
12
13#[pymethods]
14impl Guess {
15 fn __repr__(&self) -> String {
16 format!(
17 "<Guess id=\"{}\" name=\"{}\" ranking={}>",
18 self.id(),
19 self.name(),
20 self.ranking(),
21 )
22 }
23
24 #[getter]
26 const fn id(&self) -> &String {
27 &self.0.id
28 }
29
30 #[getter]
32 const fn name(&self) -> &String {
33 &self.0.name
34 }
35
36 #[getter]
38 const fn award_id(&self) -> &String {
39 &self.0.award_id
40 }
41
42 #[getter]
44 const fn flag_photo(&self) -> usize {
45 self.0.flag_photo
46 }
47
48 #[getter]
50 fn confidence(&self) -> PyResult<f32> {
51 let conf = self.0.confidence
52 .parse::<f32>()?;
53
54 Ok(conf)
55 }
56
57 #[getter]
59 const fn description(&self) -> &String {
60 &self.0.description
61 }
62
63 #[getter]
65 const fn ranking(&self) -> &String {
66 &self.0.ranking
67 }
68
69 #[getter]
71 const fn picture_path(&self) -> &String {
72 &self.0.picture_path
73 }
74
75 #[getter]
77 const fn absolute_picture_path(&self) -> &String {
78 &self.0.absolute_picture_path
79 }
80}