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
impl HttpClient
Sourcepub fn tx_log(&self, actions: Actions) -> Result<TxLogResponse, CruxError>
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.
Sourcepub fn tx_logs(&self) -> Result<TxLogsResponse, CruxError>
pub fn tx_logs(&self) -> Result<TxLogsResponse, CruxError>
Function tx_logs requests endpoint /tx-log via GET and returns a list of all transactions
Sourcepub fn entity(&self, id: CruxId) -> Result<Edn, CruxError>
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.
Sourcepub fn entity_timed(
&self,
id: CruxId,
transaction_time: Option<DateTime<FixedOffset>>,
valid_time: Option<DateTime<FixedOffset>>,
) -> Result<Edn, CruxError>
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>>.
Sourcepub fn entity_tx(&self, id: CruxId) -> Result<EntityTxResponse, CruxError>
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.
Sourcepub fn entity_tx_timed(
&self,
id: CruxId,
transaction_time: Option<DateTime<FixedOffset>>,
valid_time: Option<DateTime<FixedOffset>>,
) -> Result<EntityTxResponse, CruxError>
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>>.
Sourcepub fn entity_history(
&self,
hash: String,
order: Order,
with_docs: bool,
) -> Result<EntityHistoryResponse, CruxError>
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).
Sourcepub fn entity_history_timed(
&self,
hash: String,
order: Order,
with_docs: bool,
time: Vec<TimeHistory>,
) -> Result<EntityHistoryResponse, CruxError>
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.