concision_core/data/
mod.rs1#[doc(inline)]
7pub use self::dataset::Dataset;
8
9pub mod dataset;
10
11pub(crate) mod prelude {
12 pub use super::dataset::Dataset;
13 pub use super::{AsDataset, IntoDataset, Records};
14}
15
16pub trait DataPoint {
17 type Data;
18 type Label;
19 fn data(&self) -> &Self::Data;
20 fn label(&self) -> &Self::Label;
21}
22
23pub trait Records {
26 type Inputs;
27 type Targets;
28
29 fn inputs(&self) -> &Self::Inputs;
30
31 fn inputs_mut(&mut self) -> &mut Self::Inputs;
32
33 fn targets(&self) -> &Self::Targets;
34
35 fn targets_mut(&mut self) -> &mut Self::Targets;
36
37 fn set_inputs(&mut self, inputs: Self::Inputs) {
38 *self.inputs_mut() = inputs;
39 }
40
41 fn set_targets(&mut self, targets: Self::Targets) {
42 *self.targets_mut() = targets;
43 }
44}
45
46pub trait AsDataset<U, V> {
47 fn as_dataset(&self) -> Dataset<U, V>;
48}
49pub trait IntoDataset<U, V> {
50 fn into_dataset(self) -> Dataset<U, V>;
51}
52
53impl<U, V, A> AsDataset<U, V> for A
57where
58 A: AsRef<Dataset<U, V>>,
59 U: Clone,
60 V: Clone,
61{
62 fn as_dataset(&self) -> Dataset<U, V> {
63 self.as_ref().clone()
64 }
65}
66impl<U, V, A> IntoDataset<U, V> for A
67where
68 A: Into<Dataset<U, V>>,
69{
70 fn into_dataset(self) -> Dataset<U, V> {
71 self.into()
72 }
73}