Struct chill::Document [] [src]

pub struct Document {
    // some fields omitted
}

Contains a specific version of a document.

A Document is an in-memory representation of a document, including its content, attachments, and meta-information.

A Document may represent a document of any type: normal, design, or local.

Methods

impl Document
[src]

fn path(&self) -> &DocumentPath

fn revision(&self) -> &Revision

Returns the document's revision.

fn is_deleted(&self) -> bool

Returns true if and only if the document is deleted.

Normally, the CouchDB server returns a NotFound error if the application attempts to read a deleted document. However, the application may specify a revision when reading the document, and, if the revision marks when the document was deleted, then the server will respond successfully with a Document “stub” marked as deleted.

fn get_content<C: Deserialize>(&self) -> Result<C, Error>

Decodes and returns the document content, from a JSON object into a Rust type.

fn set_content<C: Serialize>(&mut self, new_content: &C) -> Result<()Error>

Encodes the document content, from a Rust type into a JSON object.

The set_content method modifies the Document instance but doesn't update the document on the CouchDB server. To update the document on the server, the application must use the UpdateDocument action upon the modified Document.

fn get_attachment<'a, A>(&self, att_name: A) -> Option<&Attachment> where A: Into<AttachmentName>

Returns the document's attachment of a given name, if the attachment exists.

fn insert_attachment<'a, A>(&mut self, att_name: A, content_type: Mime, content: Vec<u8>) where A: Into<AttachmentName>

Creates or replaces the document's attachment of a given name.

This method does not change state on the CouchDB server, and the newly created attachment exists only in memory on the client-side. To store the document on the CouchDB server, the client must execute an action to update the document, at which time the client will send the attachment to the server.

fn remove_attachment<'a, A>(&mut self, att_name: A) where A: Into<AttachmentName>

Deletes the document's attachment of a given name, if the attachment exists.

This method does not change state on the CouchDB server, and the newly deleted attachment will continue to exist on the CouchDB server until the client executes an action to update the document.

fn attachments(&self) -> AttachmentIter

Returns an iterator to all attachments to the document.

Trait Implementations

impl PartialEq for Document
[src]

fn eq(&self, __arg_0: &Document) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Document) -> bool

This method tests for !=.

impl Debug for Document
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Clone for Document
[src]

fn clone(&self) -> Document

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more