Memory pools support for http (#65)

* memory pools support for http
This commit is contained in:
Nikolay Kim 2021-12-06 08:07:19 +06:00 committed by GitHub
parent 2ab64627a8
commit 0315d92401
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 120 additions and 229 deletions

View file

@ -11,7 +11,7 @@ mod tree;
pub use self::de::PathDeserializer;
pub use self::path::{Path, PathIter};
pub use self::resource::ResourceDef;
pub use self::router::{ResourceInfo, Router, RouterBuilder};
pub use self::router::{Router, RouterBuilder};
pub trait Resource<T: ResourcePath> {
fn path(&self) -> &str;

View file

@ -56,7 +56,6 @@ pub(crate) enum Segment {
Dynamic {
pattern: Regex,
names: Vec<&'static str>,
len: usize,
tail: bool,
},
}
@ -375,7 +374,6 @@ impl ResourceDef {
names,
tail,
pattern: re,
len: 0,
});
pattern = rem;
@ -401,7 +399,6 @@ impl ResourceDef {
pattern,
names: Vec::new(),
tail: true,
len: 0,
});
} else {
pelems.push(Segment::Static(pattern.to_string()));
@ -720,7 +717,6 @@ mod tests {
let seg2 = Segment::Dynamic {
pattern: Regex::new("test").unwrap(),
names: Vec::new(),
len: 1,
tail: false,
};
assert!(seg != seg2);

View file

@ -4,12 +4,6 @@ use super::{IntoPattern, Resource, ResourceDef, ResourcePath};
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct ResourceId(pub u16);
/// Information about current resource
#[derive(Clone, Debug)]
pub struct ResourceInfo {
resource: ResourceId,
}
/// Resource router.
#[derive(Clone)]
pub struct Router<T, U = ()> {

View file

@ -5,7 +5,7 @@ use super::path::PathItem;
use super::resource::{ResourceDef, Segment};
use super::{Resource, ResourcePath};
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub(super) struct Tree {
key: Vec<Segment>,
items: Vec<Item>,
@ -43,15 +43,6 @@ impl Value {
}
}
impl Default for Tree {
fn default() -> Tree {
Tree {
key: Vec::new(),
items: Vec::new(),
}
}
}
impl Tree {
pub(crate) fn new(resource: &ResourceDef, value: usize) -> Tree {
if resource.tp.is_empty() {