Moved include into router.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
parent
a63a519ede
commit
fd9754d224
@ -1,14 +1,16 @@
|
||||
mod message;
|
||||
mod mtterror;
|
||||
mod name;
|
||||
mod router;
|
||||
|
||||
use message::{
|
||||
Action, Addition, CalcValue, Calculation, Clock, CreateDoc, Field, FieldType, Include, Message,
|
||||
Operand, Path, Queue, RegMsg, Register, Session,
|
||||
Action, Addition, CalcValue, Calculation, Clock, CreateDoc, Field, FieldType, Message, Operand,
|
||||
Path, Queue, RegMsg, Register, Session,
|
||||
};
|
||||
pub use message::{MsgAction, Query};
|
||||
use mtterror::MTTError;
|
||||
use name::{Name, NameType};
|
||||
use router::Include;
|
||||
use std::sync::mpsc::{channel, Receiver};
|
||||
use uuid::Uuid;
|
||||
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
use super::MTTError;
|
||||
use crate::name::{Name, NameType, Names};
|
||||
use crate::{
|
||||
name::{Name, NameType, Names},
|
||||
router::Include,
|
||||
};
|
||||
use chrono::prelude::*;
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
@ -448,41 +451,6 @@ mod messages {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash)]
|
||||
pub enum Include<T> {
|
||||
All,
|
||||
Just(T),
|
||||
}
|
||||
|
||||
impl<T: PartialEq> PartialEq for Include<T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match self {
|
||||
Include::All => true,
|
||||
Include::Just(data) => match other {
|
||||
Include::All => true,
|
||||
Include::Just(other_data) => data == other_data,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod includes {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn does_all_equal_evberything() {
|
||||
let a: Include<isize> = Include::All;
|
||||
let b: Include<isize> = Include::Just(5);
|
||||
let c: Include<isize> = 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");
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||
pub struct RouteID {
|
||||
action: Option<Action>,
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
message::{Include, Path, Route},
|
||||
message::{Path, Route},
|
||||
mtterror::MTTError,
|
||||
router::Include,
|
||||
};
|
||||
use isolang::Language;
|
||||
use std::collections::HashMap;
|
||||
|
||||
34
src/router.rs
Normal file
34
src/router.rs
Normal file
@ -0,0 +1,34 @@
|
||||
#[derive(Clone, Debug, Eq, Hash)]
|
||||
pub enum Include<T> {
|
||||
All,
|
||||
Just(T),
|
||||
}
|
||||
|
||||
impl<T: PartialEq> PartialEq for Include<T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match self {
|
||||
Include::All => true,
|
||||
Include::Just(data) => match other {
|
||||
Include::All => true,
|
||||
Include::Just(other_data) => data == other_data,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod includes {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn does_all_equal_evberything() {
|
||||
let a: Include<isize> = Include::All;
|
||||
let b: Include<isize> = Include::Just(5);
|
||||
let c: Include<isize> = 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");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user