datex_core/datex_values/
pointer.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
32
33
34
35
36
37
38
39
use std::fmt;
use crate::{global::binary_codes::BinaryCode, utils::buffers::{buffer_to_hex_advanced}};
use super::{Value, ValueResult};

pub struct Pointer {
	pub id_formatted: String
}

impl Pointer {

	pub const MAX_POINTER_ID_SIZE:usize = 26;
    pub const STATIC_POINTER_SIZE:usize = 18;

	pub fn from_id(id:Vec<u8>) -> Pointer {
		return Pointer {id_formatted: buffer_to_hex_advanced(id, "", 0, true)}
	}


}

impl Value for Pointer {
    fn to_string(&self) -> String {
		return format!("${}", self.id_formatted);
    }

    fn binary_operation(&self, _code: BinaryCode, _other: Box<dyn Value>) -> ValueResult {
        todo!()
    }

    fn cast(&self, _dx_type: super::Type) -> ValueResult {
        todo!()
    }
}

impl fmt::Display for Pointer {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", Value::to_string(self))
    }
}