HttpClient

Struct HttpClient 

Source
pub struct HttpClient { /* private fields */ }
Expand description

HttpClient has the reqwest::blocking::Client, the uri to query and the HeaderMap with all the possible headers. Default header is Content-Type: "application/edn". Synchronous request.

Implementations§

Source§

impl HttpClient

Source

pub fn tx_log(&self, actions: Actions) -> Result<TxLogResponse, CruxError>

Function tx_log requests endpoint /tx-log via POST which allow you to send actions Action to CruxDB. The “write” endpoint, to post transactions.

Source

pub fn tx_logs(&self) -> Result<TxLogsResponse, CruxError>

Function tx_logs requests endpoint /tx-log via GET and returns a list of all transactions

Source

pub fn entity(&self, id: CruxId) -> Result<Edn, CruxError>

Function entity requests endpoint /entity via POST which retrieves the last document in CruxDB. Field with CruxId is required. Response is a reqwest::Result<edn_rs::Edn> with the last Entity with that ID.

Source

pub fn entity_timed( &self, id: CruxId, transaction_time: Option<DateTime<FixedOffset>>, valid_time: Option<DateTime<FixedOffset>>, ) -> Result<Edn, CruxError>

Function entity_timed is like entity but with two optional fields transaction_time and valid_time that are of type Option<DateTime<FixedOffset>>.

Source

pub fn entity_tx(&self, id: CruxId) -> Result<EntityTxResponse, CruxError>

Function entity_tx requests endpoint /entity-tx via POST which retrieves the docs and tx infos for the last document for that ID saved in CruxDB.

Source

pub fn entity_tx_timed( &self, id: CruxId, transaction_time: Option<DateTime<FixedOffset>>, valid_time: Option<DateTime<FixedOffset>>, ) -> Result<EntityTxResponse, CruxError>

Function entity_tx_timed is like entity_tx but with two optional fields transaction_time and valid_time that are of type Option<DateTime<FixedOffset>>.

Source

pub fn entity_history( &self, hash: String, order: Order, with_docs: bool, ) -> Result<EntityHistoryResponse, CruxError>

Function entity_history requests endpoint /entity-history via GET which returns a list with all entity’s transaction history. It is possible to order it with Order , types::http::Order::Asc and types::http::Order:Desc, (second argument) and to include the document for each transaction with the boolean flag with_docs (third argument).

Source

pub fn entity_history_timed( &self, hash: String, order: Order, with_docs: bool, time: Vec<TimeHistory>, ) -> Result<EntityHistoryResponse, CruxError>

Function entity_history_timed is an txtension of the function entity_history. This function receives as the last argument a vector containing TimeHistory elements. TimeHistory can be ValidTime or TransactionTime and both have optional DateTime<Utc> params corresponding to the start-time and end-time to be queried.

Source

pub fn query(&self, query: Query) -> Result<BTreeSet<Vec<String>>, CruxError>

Function query requests endpoint /query via POST which retrives a Set containing a vector of the values defined by the function Query::find - github example. Argument is a query of the type Query.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,