-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
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
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,18 @@ | ||
SOURCES=$(wildcard src/*.rs) | ||
|
||
|
||
all: $(SOURCES) Makefile | ||
cargo build | ||
|
||
rebuild: | ||
make clean | ||
make all | ||
|
||
test: | ||
cargo test | ||
|
||
clean: | ||
cargo clean | ||
cargo update | ||
|
||
all: |
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
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
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,62 @@ | ||
use crate::value::{Value}; | ||
use crate::metric::Metric; | ||
use crate::types::*; | ||
use easy_error::{Error, bail}; | ||
|
||
impl Value { | ||
pub fn push_inplace(&mut self, value: Value) -> Result<&mut Value, Error> { | ||
match self.dt { | ||
LIST | RESULT => { | ||
match &mut self.data { | ||
Val::List(ref mut v) => { | ||
let _ = v.push(value.clone()); | ||
} | ||
_ => { | ||
bail!("Invalid List format for push() operation"); | ||
} | ||
} | ||
return Ok(self); | ||
} | ||
QUEUE | FIFO => { | ||
match &mut self.data { | ||
Val::Queue(ref mut v) => { | ||
let _ = v.push(value.clone()); | ||
} | ||
_ => { | ||
bail!("Invalid Queue/Fifo format for push() operation"); | ||
} | ||
} | ||
return Ok(self) | ||
} | ||
LAMBDA => { | ||
match &mut self.data { | ||
Val::Lambda(ref mut v) => { | ||
let _ = v.push(value.clone()); | ||
} | ||
_ => { | ||
bail!("Invalid Lambda format for push() operation"); | ||
} | ||
} | ||
return Ok(self); | ||
} | ||
METRICS => { | ||
if value.dt != FLOAT { | ||
return Ok(self); | ||
} | ||
match &mut self.data { | ||
Val::Metrics(ref mut v) => { | ||
let _ = &v.push(Metric::new(value.cast_float().unwrap())); | ||
let _ = &v.remove(0); | ||
return Ok(self); | ||
} | ||
_ => { | ||
bail!("Invalid Metric format for push() operation"); | ||
} | ||
} | ||
} | ||
_ => { | ||
bail!("This Value do not support push() operation"); | ||
} | ||
} | ||
} | ||
} |
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