safe-vk 1.2.0

A simple library to create your own vk bot for conversations
Documentation
use crate::util::Shape;
use serde_json::Error as SerdeJsonError;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    // #[error("Dimension index {dim} exceeds the maximum allowed shape dimensions (5x10) for shape {shape:?}")]
    // DimOutOfRange { shape: Shape, dim: i32 },
    #[error("Expected status success (1) but got uknown status {status}")]
    EventAnswerUnkownStatus { status: i8 },

    #[error("Expected some content but got nothing in {from}")]
    NoContent { from: &'static str },

    #[error("Serde JSON error: {0}")]
    SerdeJson(#[from] SerdeJsonError),

    #[error("Reqwest error: {0}")]
    Reqwest(#[from] reqwest::Error),

    #[error("Dimension index {dim} exceeds the maximum allowed shape dimensions (5x10) for shape {shape:?}")]
    DimOutOfRange { shape: Shape, dim: i32 },

    /// The event history has become outdated or has been partially lost. This can occur if the client fails to
    /// poll the server in a timely manner, causing a gap in the event sequence. The client should continue polling
    /// with the new `ts` value provided. This is not a critical error but indicates that some events might have been missed.
    #[error("LongPoll history is outdated or partially lost. To continue receiving updates, use the new 'ts' key provided: {new_ts}.")]
    EventsOutdated { new_ts: String },

    /// The session key used for the Long Poll connection has expired. This requires obtaining a new session key by
    /// calling the `groups.getLongPollServer` method again. Expired keys are common and expected to happen from time
    /// to time; they simply indicate that the connection to the Long Poll server needs to be refreshed.
    #[error("The LongPoll session key has expired. Obtain a new key by calling 'groups.getLongPollServer' again.")]
    KeyExpired,

    /// All session information has been lost, necessitating the initiation of a new Long Poll session. This error
    /// typically indicates that the server and key information are no longer valid, possibly due to a significant
    /// lapse in polling or server-side changes. Start a new session by re-fetching the server, key, and 'ts' values.
    #[error("The LongPoll session's information is lost. Start a new session by re-fetching the server, key, and 'ts' values.")]
    InformationLost,
}

pub type Result<T> = std::result::Result<T, Error>;