diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index 6355d40..d541fca 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -51,7 +51,9 @@ jobs: # * clippy --all-targets causes clippy to run against tests and examples which it doesnt do by default. run: cargo hack --feature-powerset clippy --all-targets --locked ${{ matrix.cargo_flags }} -- -D warnings - name: Ensure that tests pass - run: cargo test ${{ matrix.cargo_flags }} --all-features --all-targets -- --nocapture + run: | + cargo test --doc ${{ matrix.cargo_flags }} --all-features -- --show-output --nocapture + cargo test ${{ matrix.cargo_flags }} --all-features --all-targets -- --nocapture - name: Ensure that tests did not create or modify any files that arent .gitignore'd run: | if [ -n "$(git status --porcelain)" ]; then diff --git a/prometheus-remote/src/lib_vsri.rs b/prometheus-remote/src/lib_vsri.rs index 8acec72..85bd473 100644 --- a/prometheus-remote/src/lib_vsri.rs +++ b/prometheus-remote/src/lib_vsri.rs @@ -88,7 +88,7 @@ pub struct Vsri { impl Vsri { /// Creates the index, it doesn't create the file in the disk /// flush needs to be called for that - pub fn new(filename: &String) -> Self { + pub fn new(filename: &str) -> Self { debug!("[INDEX] Creating new index!"); let segments: Vec<[i32; 4]> = Vec::new(); Vsri { diff --git a/vsri/src/lib.rs b/vsri/src/lib.rs index 53529e6..247bc48 100644 --- a/vsri/src/lib.rs +++ b/vsri/src/lib.rs @@ -56,18 +56,22 @@ pub fn start_day_ts(dt: DateTime) -> i64 { /// # Examples /// Creating a new index, metric is of expected time 0, but for sure location of X is 0 /// ```no_run -/// let vsri = Vsri::new("metric_name", 0, 0); +/// # use vsri::Vsri; +/// let vsri = Vsri::new("metric_name"); /// vsri.flush(); /// ``` /// Updating an index, adding point at time 5sec /// ```no_run -/// let vsri = Vsri::load("metric_name").unwrap().update_for_point(5); +/// +/// # use vsri::Vsri; +/// let mut vsri = Vsri::load("metric_name").unwrap(); +/// vsri.update_for_point(5).unwrap(); /// vsri.flush(); /// ``` /// Fetch a sample location from the index given a timestamp /// ```no_run -/// let vsri = Vsri::load("metric_name").unwrap(); -/// vsri.get_sample_location("metric_name", 5); +/// # use vsri::Vsri; +/// let vsri = Vsri::get_sample_location("metric_name", 5); /// ``` /// Index Structure @@ -90,7 +94,7 @@ pub struct Vsri { impl Vsri { /// Creates the index, it doesn't create the file in the disk /// flush needs to be called for that - pub fn new(filename: &String) -> Self { + pub fn new(filename: &str) -> Self { debug!("[INDEX] Creating new index!"); Vsri { index_file: filename.to_string(), @@ -102,8 +106,8 @@ impl Vsri { /// Given a filename and a time location, returns the sample location in the /// data file. Or None in case it doesn't exist. - pub fn get_sample_location(filename: String, y: i32) -> Option { - let vsri = match Vsri::load(&filename) { + pub fn get_sample_location(filename: &str, y: i32) -> Option { + let vsri = match Vsri::load(filename) { Ok(vsri) => vsri, Err(_err) => return None, };