datex_core/datex_values/
pointer.rs1use std::fmt;
2use crate::{global::binary_codes::BinaryCode, utils::buffers::{buffer_to_hex_advanced}};
3use super::{Value, ValueResult};
4
5pub struct Pointer {
6 pub id_formatted: String
7}
8
9impl Pointer {
10
11 pub const MAX_POINTER_ID_SIZE:usize = 26;
12 pub const STATIC_POINTER_SIZE:usize = 18;
13
14 pub fn from_id(id:Vec<u8>) -> Pointer {
15 return Pointer {id_formatted: buffer_to_hex_advanced(id, "", 0, true)}
16 }
17
18
19}
20
21impl Value for Pointer {
22 fn to_string(&self) -> String {
23 return format!("${}", self.id_formatted);
24 }
25
26 fn binary_operation(&self, _code: BinaryCode, _other: Box<dyn Value>) -> ValueResult {
27 todo!()
28 }
29
30 fn cast(&self, _dx_type: super::Type) -> ValueResult {
31 todo!()
32 }
33}
34
35impl fmt::Display for Pointer {
36 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 write!(f, "{}", Value::to_string(self))
38 }
39}