-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: fields and message expansion feature
- Loading branch information
Showing
36 changed files
with
1,085 additions
and
155 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ members = [".", "crate/encstr"] | |
[workspace.package] | ||
repository = "https://github.com/pamburus/hl" | ||
authors = ["Pavel Ivanov <[email protected]>"] | ||
version = "0.29.7-alpha.1" | ||
version = "0.30.0-alpha.1" | ||
edition = "2021" | ||
license = "MIT" | ||
|
||
|
@@ -53,11 +53,13 @@ encstr = { path = "./crate/encstr" } | |
enum-map = "2" | ||
flate2 = "1" | ||
heapless = "0" | ||
heapopt = { path = "./crate/heapopt" } | ||
hex = "0" | ||
htp = { git = "https://github.com/pamburus/htp.git" } | ||
humantime = "2" | ||
itertools = "0.13" | ||
itoa = { version = "1", default-features = false } | ||
mline = { path = "./crate/mline" } | ||
notify = { version = "6", features = ["macos_kqueue"] } | ||
nu-ansi-term = "0" | ||
num_cpus = "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,5 @@ impl fmt::Display for Error { | |
} | ||
} | ||
} | ||
|
||
impl std::error::Error for Error {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
description = "Optimized collections for minimal heap usage" | ||
name = "heapopt" | ||
version = "0.1.0" | ||
workspace = "../.." | ||
repository.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
heapless = "0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#[derive(Default)] | ||
pub struct Vec<T, const N: usize> { | ||
head: heapless::Vec<T, N>, | ||
tail: std::vec::Vec<T>, | ||
} | ||
|
||
impl<T, const N: usize> Vec<T, N> { | ||
#[inline] | ||
pub fn new() -> Self { | ||
Self { | ||
head: heapless::Vec::new(), | ||
tail: std::vec::Vec::new(), | ||
} | ||
} | ||
|
||
#[inline] | ||
pub fn iter(&self) -> std::iter::Chain<std::slice::Iter<T>, std::slice::Iter<T>> { | ||
self.head.iter().chain(self.tail.iter()) | ||
} | ||
|
||
#[inline] | ||
pub fn push(&mut self, value: T) { | ||
if let Err(value) = self.head.push(value) { | ||
self.tail.push(value); | ||
} | ||
} | ||
|
||
#[inline] | ||
pub fn pop(&mut self) -> Option<T> { | ||
if let Some(value) = self.tail.pop() { | ||
return Some(value); | ||
} | ||
self.head.pop() | ||
} | ||
|
||
#[inline] | ||
pub fn len(&self) -> usize { | ||
self.head.len() + self.tail.len() | ||
} | ||
|
||
#[inline] | ||
pub fn is_empty(&self) -> bool { | ||
self.head.is_empty() && self.tail.is_empty() | ||
} | ||
|
||
#[inline] | ||
pub fn resize(&mut self, new_len: usize, value: T) | ||
where | ||
T: Clone, | ||
{ | ||
if new_len <= self.head.len() { | ||
self.head.truncate(new_len); | ||
self.tail.clear(); | ||
} else if new_len <= self.len() { | ||
self.tail.resize(new_len - self.head.len(), value); | ||
} | ||
} | ||
|
||
#[inline] | ||
pub fn clear(&mut self) { | ||
self.head.clear(); | ||
self.tail.clear(); | ||
} | ||
} | ||
|
||
impl<T, const N: usize> std::ops::Deref for Vec<T, N> { | ||
type Target = [T]; | ||
|
||
#[inline] | ||
fn deref(&self) -> &Self::Target { | ||
self.head.as_slice() | ||
} | ||
} | ||
|
||
impl<T, const N: usize> std::ops::DerefMut for Vec<T, N> { | ||
#[inline] | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
self.head.as_mut_slice() | ||
} | ||
} | ||
|
||
impl<T, const N: usize> std::ops::Index<usize> for Vec<T, N> { | ||
type Output = T; | ||
|
||
#[inline] | ||
fn index(&self, index: usize) -> &Self::Output { | ||
if index < self.head.len() { | ||
&self.head[index] | ||
} else { | ||
&self.tail[index - self.head.len()] | ||
} | ||
} | ||
} | ||
|
||
impl<T, const N: usize> std::ops::IndexMut<usize> for Vec<T, N> { | ||
#[inline] | ||
fn index_mut(&mut self, index: usize) -> &mut Self::Output { | ||
if index < self.head.len() { | ||
&mut self.head[index] | ||
} else { | ||
&mut self.tail[index - self.head.len()] | ||
} | ||
} | ||
} | ||
|
||
impl<T, const N: usize> std::fmt::Debug for Vec<T, N> | ||
where | ||
T: std::fmt::Debug, | ||
{ | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
f.debug_list().entries(self.iter()).finish() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
description = "Multi-line string manipulation library for Rust" | ||
name = "mline" | ||
version = "0.1.0" | ||
workspace = "../.." | ||
repository.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
heapopt = { path = "../heapopt" } | ||
itertools = "0.13" |
Oops, something went wrong.