Skip to main content

open_timeline_core/
lib.rs

1// SPDX-License-Identifier: MIT
2
3//!
4//! *Part of the wider OpenTimeline project*
5//!
6//! This crate defines the basic datatypes used across the OpenTimeline project
7//! (web API, desktop application, renderer).
8//!
9//! This crate is designed to be used by the rest of the OpenTimeline project,
10//! as well as by other 3rd party projects that want to interact with
11//! OpenTimeline (e.g. via it's JSON web API).
12//!
13//! This crate aims to provide APIs for each type so that if a type is
14//! instantiated, the developer can be sure it's valid.
15//!
16
17mod date;
18mod entity;
19mod id;
20mod name;
21mod reduced;
22mod timeline_edit;
23mod timeline_view;
24
25pub use date::*;
26pub use entity::*;
27pub use id::*;
28pub use name::*;
29pub use reduced::*;
30pub use timeline_edit::*;
31pub use timeline_view::*;
32
33#[macro_use]
34extern crate log;
35
36// TODO: is this used anywhere (variants could/should hold the more specific Errors)
37/// Errors that can be returned by OpenTimeline
38#[derive(Debug)]
39pub enum OpenTimelineError {
40    Date,
41    Entity,
42    Id,
43    Name,
44    Tags,
45    Timeline,
46}
47
48/// Mark that a type has both an [`OpenTimelineId`] and a [`Name`], and setup
49/// getters and setters for both
50pub trait HasIdAndName {
51    /// Get the ID
52    fn id(&self) -> Option<OpenTimelineId>;
53
54    /// Set the ID - the [`OpenTimelineId`] passed in must have been
55    /// initialised, and therefore is guaranteed to be valid
56    fn set_id(&mut self, id: OpenTimelineId);
57
58    /// Get the name
59    fn name(&self) -> &Name;
60
61    /// Set the name - the [`Name`] passed in must have been initialised, and
62    /// therefore is guaranteed to be valid
63    fn set_name(&mut self, name: Name);
64}