Skip to content

Commit

Permalink
since/limit mut methods
Browse files Browse the repository at this point in the history
Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Aug 21, 2024
1 parent 385a1af commit 4c89dcb
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Filter {
unsafe { &*(self.as_ptr()) }.num_elements
}

pub fn limit(self, limit: u64) -> Self {
pub fn limit_mut(self, limit: u64) -> Self {
for field in self.mut_iter() {
if let MutFilterField::Limit(val) = field {
*val = limit;
Expand All @@ -199,7 +199,7 @@ impl Filter {
Filter::copy_from(&self).limit(limit).build()
}

pub fn until(self, until: u64) -> Self {
pub fn until_mut(self, until: u64) -> Self {
for field in self.mut_iter() {
if let MutFilterField::Until(val) = field {
*val = until;
Expand All @@ -210,7 +210,37 @@ impl Filter {
Filter::copy_from(&self).until(until).build()
}

pub fn since(self, since: u64) -> Self {
pub fn since(&self) -> Option<u64> {
for field in self {
if let FilterField::Since(since) = field {
return Some(since);
}
}

None
}

pub fn limit(&self) -> Option<u64> {
for field in self {
if let FilterField::Limit(limit) = field {
return Some(limit);
}
}

None
}

pub fn until(&self) -> Option<u64> {
for field in self {
if let FilterField::Until(until) = field {
return Some(until);
}
}

None
}

pub fn since_mut(self, since: u64) -> Self {
for field in self.mut_iter() {
if let MutFilterField::Since(val) = field {
*val = since;
Expand Down

0 comments on commit 4c89dcb

Please sign in to comment.