Crates.io | buffer-trigger |
lib.rs | buffer-trigger |
version | 0.7.0 |
source | src |
created_at | 2020-08-01 07:28:26.70881 |
updated_at | 2021-01-06 12:38:29.386808 |
description | A data collection trigger based on the maximum number and refresh time |
homepage | |
repository | https://github.com/liangyongrui/buffer-trigger |
max_upload_size | |
id | 271876 |
size | 45,273 |
A data collection trigger based on the maximum number and refresh time.
scenes to be used:
more see tests
#[macro_use]
extern crate lazy_static;
use buffer_trigger::{
self, buffer_trigger_sync, buffer_trigger_sync::BufferTrigger,
};
use std::{thread, time::Duration};
lazy_static! {
static ref SIMPLE_BUFFER_TRIGGER: buffer_trigger_sync::Simple<i32, Vec<i32>> =
buffer_trigger_sync::SimpleBuilder::builder(Vec::default)
.name("test".to_owned())
.accumulator(|c, e| c.push(e))
.consumer(|c| log::info!("{:?}", c))
.max_len(15)
.interval(Duration::from_millis(500))
.build();
}
#[test]
fn simple_test() {
let _ = env_logger::builder()
.is_test(true)
.filter_level(LevelFilter::Debug)
.try_init();
for i in 0..100 {
SIMPLE_BUFFER_TRIGGER.push(i);
}
thread::sleep(Duration::from_secs(5));
}
output:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
[15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
[30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]
[45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
[60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74]
[75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89]
[90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
This project is still under development. The following features with the check marks are supported.
If you are concerned about an unimplemented feature, please tell me and I will finish writing it ASAP.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions