rust_dynamic/
create_matrix.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use crate::value::{Value, timestamp_ms};
use std::collections::HashMap;
use nanoid::nanoid;
use crate::types::*;

impl Value {
    pub fn matrix() -> Self {
        Self {
            id:   nanoid!(),
            stamp:  timestamp_ms(),
            dt:   MATRIX,
            q:    100.0,
            data: Val::Matrix(Vec::new()),
            attr: Vec::new(),
            curr: -1,
            tags:   HashMap::new(),
        }
    }
    pub fn from_matrix(value: Vec<Vec<Value>>) -> Self {
        Self {
            id:   nanoid!(),
            stamp:  timestamp_ms(),
            dt:   MATRIX,
            q:    100.0,
            data: Val::Matrix(value),
            attr: Vec::new(),
            curr: -1,
            tags:   HashMap::new(),
        }
    }
}