1use serde::{Deserialize, Serialize};
4
5use super::AppEvent;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct ModelSummary {
13 pub id: i64,
15 pub name: String,
17 pub file_path: String,
19 #[serde(skip_serializing_if = "Option::is_none")]
21 pub architecture: Option<String>,
22 #[serde(skip_serializing_if = "Option::is_none")]
24 pub quantization: Option<String>,
25}
26
27impl ModelSummary {
28 pub fn new(
30 id: i64,
31 name: impl Into<String>,
32 file_path: impl Into<String>,
33 architecture: Option<String>,
34 quantization: Option<String>,
35 ) -> Self {
36 Self {
37 id,
38 name: name.into(),
39 file_path: file_path.into(),
40 architecture,
41 quantization,
42 }
43 }
44}
45
46impl AppEvent {
47 pub const fn model_added(model: ModelSummary) -> Self {
49 Self::ModelAdded { model }
50 }
51
52 pub const fn model_removed(model_id: i64) -> Self {
54 Self::ModelRemoved { model_id }
55 }
56
57 pub const fn model_updated(model: ModelSummary) -> Self {
59 Self::ModelUpdated { model }
60 }
61}