teo_runtime/model/field/
index.rs1use std::sync::Arc;
2use serde::Serialize;
3use super::super::index::Type;
4use crate::sort::Sort;
5
6#[derive(Debug, Clone, PartialEq)]
7pub struct Index {
8 inner: Arc<Inner>
9}
10
11#[derive(Debug, Clone, PartialEq, Serialize)]
12struct Inner {
13 r#type: Type,
14 name: String,
15 sort: Sort,
16 length: Option<usize>,
17}
18
19impl Index {
20
21 pub fn new(r#type: Type, name: String, sort: Sort, length: Option<usize>) -> Self {
22 Self {
23 inner: Arc::new(Inner {
24 r#type,
25 name,
26 sort,
27 length,
28 })
29 }
30 }
31
32 pub fn r#type(&self) -> Type {
33 self.inner.r#type
34 }
35
36 pub fn name(&self) -> &str {
37 self.inner.name.as_str()
38 }
39
40 pub fn sort(&self) -> Sort {
41 self.inner.sort
42 }
43
44 pub fn length(&self) -> Option<usize> {
45 self.inner.length
46 }
47}
48
49impl Serialize for Index {
50 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
51 self.inner.serialize(serializer)
52 }
53}