chainsight-sdk-v2-types 0.1.0

Chainsight SDK for DFINITY Internet Computer
Documentation
use candid::CandidType;
use serde::{Deserialize, Serialize};

#[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub struct Key {
    pub id: String,
}
impl From<String> for Key {
    fn from(id: String) -> Self {
        Key { id }
    }
}
impl Into<String> for Key {
    fn into(self) -> String {
        self.id
    }
}
#[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub struct Value {
    pub value: String,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug, Hash)]
pub struct SnapshotId {
    pub id: String,
}

impl From<String> for SnapshotId {
    fn from(id: String) -> Self {
        SnapshotId { id }
    }
}
impl Into<String> for SnapshotId {
    fn into(self) -> String {
        self.id
    }
}
#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct Snapshot {
    pub id: SnapshotId,
    pub value: SnapshotValue,
    pub timestamp: u64,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct SnapshotData {
    pub raw: Vec<u8>,
    pub value: Vec<u8>,
    pub proof: Vec<u8>,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct SnapshotValue {
    pub raw: Vec<u8>,
}
#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct SnapshotIds {
    pub ids: Vec<SnapshotId>,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug, Default)]
pub struct QueryOptions {
    pub from_timestamp: Option<i64>,
    pub to_timestamp: Option<i64>,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct BatchQueryParams {
    pub params: Vec<(String, QueryOptions)>,
}