Skip to main content

HttpAdapter

Struct HttpAdapter 

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

HTTP adapter that talks to a remote CouchDB instance.

Implementations§

Source§

impl HttpAdapter

Source

pub fn new(url: &str) -> Self

Create a new HTTP adapter pointing at a CouchDB database URL.

The URL should include the database name, e.g. http://localhost:5984/mydb or http://admin:password@localhost:5984/mydb

Source

pub fn with_client(url: &str, client: Client) -> Self

Create a new HTTP adapter with a custom reqwest client.

Source

pub fn with_auth_client(url: &str, auth: &AuthClient) -> Self

Create a new HTTP adapter using an authenticated client.

The AuthClient must have been logged in already; its internal reqwest client (with cookie store) will be shared with this adapter.

Trait Implementations§

Source§

impl Adapter for HttpAdapter

Source§

fn info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<DbInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get database information: name, document count, update sequence.
Source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, opts: GetOptions, ) -> Pin<Box<dyn Future<Output = Result<Document>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve a single document by ID. Read more
Source§

fn bulk_docs<'life0, 'async_trait>( &'life0 self, docs: Vec<Document>, opts: BulkDocsOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<DocResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Write multiple documents atomically. Read more
Source§

fn all_docs<'life0, 'async_trait>( &'life0 self, opts: AllDocsOptions, ) -> Pin<Box<dyn Future<Output = Result<AllDocsResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Query all documents, optionally filtered by key range.
Source§

fn changes<'life0, 'async_trait>( &'life0 self, opts: ChangesOptions, ) -> Pin<Box<dyn Future<Output = Result<ChangesResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get changes since a given sequence number.
Source§

fn revs_diff<'life0, 'async_trait>( &'life0 self, revs: HashMap<String, Vec<String>>, ) -> Pin<Box<dyn Future<Output = Result<RevsDiffResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Compare sets of document revisions to find which ones the adapter is missing. Used during replication to avoid transferring data the target already has.
Source§

fn bulk_get<'life0, 'async_trait>( &'life0 self, docs: Vec<BulkGetItem>, ) -> Pin<Box<dyn Future<Output = Result<BulkGetResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch multiple documents by ID and revision in a single request. Used during replication to efficiently retrieve missing documents.
Source§

fn put_attachment<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, rev: &'life3 str, data: Vec<u8>, content_type: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<DocResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Store an attachment on a document.
Source§

fn get_attachment<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, opts: GetAttachmentOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieve raw attachment data.
Source§

fn remove_attachment<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, doc_id: &'life1 str, att_id: &'life2 str, rev: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<DocResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remove an attachment from a document. Read more
Source§

fn get_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve a local document (not replicated, used for checkpoints).
Source§

fn put_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, doc: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Write a local document (not replicated, used for checkpoints).
Source§

fn remove_local<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a local document.
Source§

fn compact<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Compact the database: remove old revisions, clean up unreferenced attachment data.
Source§

fn destroy<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Destroy the database and all its data.
Source§

fn purge<'life0, 'async_trait>( &'life0 self, req: HashMap<String, Vec<String>>, ) -> Pin<Box<dyn Future<Output = Result<PurgeResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Purge (permanently remove) document revisions.
Source§

fn get_security<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<SecurityDocument>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the security document for this database.
Source§

fn put_security<'life0, 'async_trait>( &'life0 self, doc: SecurityDocument, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the security document for this database.
Source§

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), RouchError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Close the database, releasing any held resources. Default implementation is a no-op.

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, 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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