1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::sketchbook::JsonSerde;
use serde::{Deserialize, Serialize};

/// Structure for receiving data about network sampling details from the frontend.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SamplingData {
    pub count: usize,
    pub seed: Option<u64>,
    pub path: String,
}

impl<'de> JsonSerde<'de> for SamplingData {}

impl SamplingData {
    /// Create new `SamplingData` object given all its fields.
    pub fn new(count: usize, seed: Option<u64>, path: &str) -> SamplingData {
        SamplingData {
            count,
            seed,
            path: path.to_string(),
        }
    }
}