david пре 3 недеља
родитељ
комит
6aff7760e8
3 измењених фајлова са 167 додато и 2 уклоњено
  1. 103 1
      Cargo.lock
  2. 4 1
      Cargo.toml
  3. 60 0
      src/data.rs

+ 103 - 1
Cargo.lock

@@ -17,6 +17,18 @@ version = "1.0.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
 
+[[package]]
+name = "anyhow"
+version = "1.0.91"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"
+
+[[package]]
+name = "autocfg"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
+
 [[package]]
 name = "backtrace"
 version = "0.3.73"
@@ -59,6 +71,12 @@ version = "0.2.158"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
 
+[[package]]
+name = "libm"
+version = "0.2.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
+
 [[package]]
 name = "memchr"
 version = "2.7.4"
@@ -74,6 +92,80 @@ dependencies = [
  "adler",
 ]
 
+[[package]]
+name = "num"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
+dependencies = [
+ "num-bigint",
+ "num-complex",
+ "num-integer",
+ "num-iter",
+ "num-rational",
+ "num-traits",
+]
+
+[[package]]
+name = "num-bigint"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
+dependencies = [
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-complex"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
+name = "num-integer"
+version = "0.1.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
+name = "num-iter"
+version = "0.1.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
+dependencies = [
+ "autocfg",
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-rational"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
+dependencies = [
+ "num-bigint",
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+ "libm",
+]
+
 [[package]]
 name = "object"
 version = "0.36.4"
@@ -89,6 +181,15 @@ version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
 
+[[package]]
+name = "point"
+version = "0.1.5"
+source = "git+https://git.red-green.com/david/point#5776731e72b6f2dbbdaf887236b1622cc3b3c6b6"
+dependencies = [
+ "anyhow",
+ "num",
+]
+
 [[package]]
 name = "proc-macro2"
 version = "1.0.86"
@@ -135,8 +236,9 @@ dependencies = [
 
 [[package]]
 name = "shared"
-version = "0.1.1"
+version = "0.1.2"
 dependencies = [
+ "point",
  "serde",
  "tokio",
 ]

+ 4 - 1
Cargo.toml

@@ -1,12 +1,15 @@
 [package]
 name = "shared"
-version = "0.1.1"
+version = "0.1.2"
 edition = "2021"
 
 [features]
 cast_into = []
 serde = ["dep:serde"]
+point = ["serde", "dep:point"]
 
 [dependencies]
 tokio = { version = "1.40.0", features = ["macros", "rt", "rt-multi-thread", "sync", "time"] }
 serde = { version = "1.0", features = ["derive"], optional = true}
+point = { git = "https://git.red-green.com/david/point", version = "0.1.5", optional = true }
+

+ 60 - 0
src/data.rs

@@ -3,6 +3,7 @@ use std::{collections::HashMap, fmt::Display, slice::{SliceIndex, Iter, IterMut}
 use crate::Shared;
 
 #[cfg(not(feature = "serde"))]
+#[cfg(not(feature = "point"))]
 #[derive(Debug, PartialEq, Clone)]
 pub enum Data {
     None,
@@ -25,6 +26,7 @@ pub enum Data {
 }
 
 #[cfg(feature="serde")]
+#[cfg(not(feature = "point"))]
 #[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
 pub enum Data {
     None,
@@ -46,6 +48,64 @@ pub enum Data {
     Map(HashMap<String, Data>),
 }
 
+#[cfg(not(feature = "serde"))]
+#[cfg(feature = "point")]
+#[derive(Debug, PartialEq, Clone)]
+pub enum Data {
+    None,
+    String(String),
+    I8(i8),
+    I16(i16),
+    I32(i32),
+    I64(i64),
+    I128(i128),
+    U8(u8),
+    U16(u16),
+    U32(u32),
+    U64(u64),
+    U128(u128),
+    F32(f32),
+    F64(f64),
+    Bool(bool),
+    Vec(Vec<Data>),
+    Map(HashMap<String, Data>),
+    PI32(Point<i32>),
+    PI64(Point<i64>),
+    PI128(Point<i128>),
+    PU32(Point<u32>),
+    PU64(Point<u64>),
+    PU128(Point<u128>),
+}
+
+#[cfg(feature="serde")]
+#[cfg(feature = "point")]
+#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
+pub enum Data {
+    None,
+    String(String),
+    I8(i8),
+    I16(i16),
+    I32(i32),
+    I64(i64),
+    I128(i128),
+    U8(u8),
+    U16(u16),
+    U32(u32),
+    U64(u64),
+    U128(u128),
+    F32(f32),
+    F64(f64),
+    Bool(bool),
+    Vec(Vec<Data>),
+    Map(HashMap<String, Data>),
+    PI32(Point<i32>),
+    PI64(Point<i64>),
+    PI128(Point<i128>),
+    PU32(Point<u32>),
+    PU64(Point<u64>),
+    PU128(Point<u128>),
+}
+
 impl Default for Data {
     fn default() -> Self {
         Self::None