ORM

Trait ORM 

Source
pub trait ORM {
    // Required methods
    fn json<T: DeserializeOwned>(&mut self) -> Result<T, RequestError>;
    fn get_by_id(&mut self, id: &str) -> &mut SanityClient;
    fn get_by_ids(&mut self, ids: &[&str]) -> &mut SanityClient;
    fn send(&mut self) -> impl Future<Output = Result<&mut Self, RequestError>>;
}
Expand description

A trait defining the interface for an Object-Relational Mapper (ORM). This trait provides methods for interacting with a data source, retrieving data in JSON format, and performing CRUD operations.

Required Methods§

Source

fn json<T: DeserializeOwned>(&mut self) -> Result<T, RequestError>

Serialized reterived data into JSON.

§Type Parameters
  • T: The type to deserialize the JSON data into. Must implement DeserializeOwned.
§Returns
  • Result<T, RequestError>: A Result containing the deserialized data or a RequestError if an error occurred.
Source

fn get_by_id(&mut self, id: &str) -> &mut SanityClient

Retrieves a single record from based on its ID.

§Arguments
  • id: The ID of the record to retrieve.
§Returns
  • &mut SanityClient: A mutable reference to the SanityClient. This likely needs further clarification depending on the actual implementation. Consider returning a Result instead.
Source

fn get_by_ids(&mut self, ids: &[&str]) -> &mut SanityClient

Retrieves multiple records based on their IDs.

§Arguments
  • ids: A slice of IDs of the records to retrieve.
§Returns
  • &mut SanityClient: A mutable reference to the SanityClient. This likely needs further clarification depending on the actual implementation. Consider returning a Result instead.
Source

fn send(&mut self) -> impl Future<Output = Result<&mut Self, RequestError>>

Sends a request to the data source.

§Returns
  • impl Future<Output = Result<&mut Self, RequestError>>: A future that resolves to a Result containing a mutable reference to Self or a RequestError if an error occurred.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§