made_core/entities/
context_summary.rs1use serde::{Deserialize, Serialize};
2
3use crate::error::DomainError;
4use crate::value_objects::Attributes;
5
6use super::external_context_validation::{validate_text, MAX_ITEM_TITLE_LEN};
7
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10pub struct ContextSummary {
11 text: String,
12 #[serde(default)]
13 attributes: Attributes,
14}
15
16impl ContextSummary {
17 pub fn new(text: impl Into<String>, attributes: Attributes) -> Result<Self, DomainError> {
18 let text = text.into();
19 Ok(Self {
20 text: validate_text(&text, "external_context.summary.text", MAX_ITEM_TITLE_LEN)?,
21 attributes,
22 })
23 }
24
25 #[must_use]
26 pub fn text(&self) -> &str {
27 &self.text
28 }
29
30 #[must_use]
31 pub fn attributes(&self) -> &Attributes {
32 &self.attributes
33 }
34}