From 7cfc982be9a7643c5c1e1bfea279268de58a2359 Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Fri, 26 Dec 2025 15:03:42 -0500 Subject: [PATCH] moved path to router. --- src/lib.rs | 4 +-- src/message.rs | 80 +------------------------------------------------- src/name.rs | 4 +-- src/router.rs | 28 +++++++++++++++--- 4 files changed, 29 insertions(+), 87 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 883680f..1e1e67d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,12 +5,12 @@ mod router; use message::{ Action, Addition, CalcValue, Calculation, Clock, CreateDoc, Field, FieldType, Message, Operand, - Path, Queue, RegMsg, Register, Session, + Queue, RegMsg, Register, Session, }; pub use message::{MsgAction, Query}; use mtterror::MTTError; use name::{Name, NameType}; -use router::Include; +use router::{Include, Path}; use std::sync::mpsc::{channel, Receiver}; use uuid::Uuid; diff --git a/src/message.rs b/src/message.rs index e3ef4c9..37c5a90 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,7 +1,7 @@ use super::MTTError; use crate::{ name::{Name, NameType, Names}, - router::Include, + router::{Include, Path}, }; use chrono::prelude::*; use std::{ @@ -66,48 +66,6 @@ impl From<&MsgAction> for Action { } } -/* -#[derive(Clone, Debug, Eq, Hash, PartialEq)] -enum NameID { - ID(Uuid), - Name(String), - None, -} - -impl NameID { - fn is_none(&self) -> bool { - match self { - Self::None => true, - _ => false, - } - } -} - -impl From<&str> for NameID { - fn from(value: &str) -> Self { - Self::Name(value.to_string()) - } -} - -impl From for NameID { - fn from(value: String) -> Self { - Self::Name(value) - } -} - -impl From for NameID { - fn from(value: Uuid) -> Self { - Self::ID(value) - } -} - -impl From<&NameID> for NameID { - fn from(value: &NameID) -> Self { - value.clone() - } -} -*/ - #[derive(Clone, Debug)] pub enum MsgAction { Addition(Addition), @@ -532,23 +490,6 @@ mod route_ids { } } -#[derive(Clone, Debug)] -pub struct Path { - pub msg_id: Include, - pub doc: Include, - pub action: Include, -} - -impl Path { - pub fn new(id: Include, doc: Include, action: Include) -> Self { - Self { - msg_id: id, - doc: doc, - action: action, - } - } -} - #[derive(Clone, Debug)] pub enum RegMsg { AddRoute(Path), @@ -744,25 +685,6 @@ mod routes { } } -/* -#[derive(Clone, Debug, Eq, PartialEq)] -struct RouteRequest { - msg_id: Include, - doc_name: Include, - action: Include, -} - -impl RouteRequest { - fn new(msg_id: Include, doc_name: Include, action: Include) -> Self { - Self { - msg_id: msg_id, - doc_name: doc_name, - action: action, - } - } -} -*/ - struct RouteStorage { data: HashMap>, } diff --git a/src/name.rs b/src/name.rs index 4234c68..01852ab 100644 --- a/src/name.rs +++ b/src/name.rs @@ -1,7 +1,7 @@ use crate::{ - message::{Path, Route}, + message::Route, mtterror::MTTError, - router::Include, + router::{Include, Path}, }; use isolang::Language; use std::collections::HashMap; diff --git a/src/router.rs b/src/router.rs index d8a4658..d0a47ff 100644 --- a/src/router.rs +++ b/src/router.rs @@ -1,3 +1,6 @@ +use crate::{message::Action, name::NameType}; +use uuid::Uuid; + #[derive(Clone, Debug, Eq, Hash)] pub enum Include { All, @@ -26,9 +29,26 @@ mod includes { let b: Include = Include::Just(5); let c: Include = Include::Just(7); assert!(a == a, "all should equal all"); - assert!(a == b, "all should equal some"); - assert!(b == a, "some should equal all"); - assert!(b == b, "same some should equal"); - assert!(b != c, "different somes do not equal"); + assert!(a == b, "all should equal just"); + assert!(b == a, "just should equal all"); + assert!(b == b, "same just should equal"); + assert!(b != c, "different justs do not equal"); + } +} + +#[derive(Clone, Debug)] +pub struct Path { + pub msg_id: Include, + pub doc: Include, + pub action: Include, +} + +impl Path { + pub fn new(id: Include, doc: Include, action: Include) -> Self { + Self { + msg_id: id, + doc: doc, + action: action, + } } }