hyperlit_model/
segment.rs1use crate::last_modification_info::LastModificationInfo;
2use crate::location::Location;
3
4pub type SegmentId = u32;
5
6#[derive(Debug, Clone, PartialEq)]
7pub struct Segment {
8 pub id: SegmentId,
10 pub title: String,
12 pub tags: Vec<String>,
14 pub text: String,
16 pub location: Location,
18 pub location_url: Option<String>,
20 pub is_included: bool,
22 pub last_modification: LastModificationInfo,
24}
25
26impl Segment {
27 pub fn new(
28 id: SegmentId,
29 title: impl Into<String>,
30 tags: Vec<String>,
31 text: impl Into<String>,
32 location: Location,
33 ) -> Segment {
34 Segment {
35 id,
36 title: title.into(),
37 tags,
38 text: text.into(),
39 location,
40 is_included: false,
41 last_modification: LastModificationInfo::default(),
42 location_url: None,
43 }
44 }
45}
46
47pub fn segments_sort_by_title(segments: &mut [&Segment]) {
48 segments.sort_by(|a, b| a.title.cmp(&b.title));
49}