Skip to main content

DataSet

Struct DataSet 

Source
pub struct DataSet {
    pub id: String,
    pub value: Value,
}
Expand description

Represents a data entry in a dataset, typically used for storing and retrieving structured data in a database.

This struct is used to represent an individual row or object in the dataset, where each entry is identified by a unique id and can hold a dynamic value in the form of a JSON object. The value field allows for flexible storage of various types of data using the serde_json::Value type, which can represent different JSON structures like strings, numbers, arrays, objects, or nulls.

§Fields

  • id: A unique identifier for the dataset entry. This is typically used as a primary key in database operations, ensuring that each entry can be retrieved, updated, or deleted based on its unique identifier. The ID is represented as a String, which can be a UUID or any other suitable format for identifying records.

  • value: The actual data associated with this entry. This is stored as a serde_json::Value type, which is a flexible and powerful representation of any valid JSON data. This allows the driver to store various data types in the database without enforcing a rigid schema. The data stored here can be a string, a number, an array, an object, or any other valid JSON structure.

§Example Usage

use serde_json::{json, Value};

let data = DataSet {
    id: "12345".to_string(),
    value: json!({"key": "value", "age": 30}),
};

In this example, data.id is the unique identifier "12345", and data.value is a JSON object containing a string and a number.

Fields§

§id: String

Unique identifier for this data entry in the dataset.

§value: Value

A flexible container for any JSON-compatible value. This can store a wide range of data structures such as strings, numbers, arrays, objects, etc.

Trait Implementations§

Source§

impl Debug for DataSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DataSet

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for DataSet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,