Module couchdb::path
[−]
[src]
The path
module provides types for identifying databases, documents, etc.
Summary
The
path
module provides a suite of types for names, ids, and paths—all of which are used to specify the location of CouchDB resources, such as databases, documents, and views.Both names and ids are percent-decoded, but whereas a name comprises exactly one path segment, an id may comprise more.
Both names and ids are useful for constructing query parameters, headers, and capturing CouchDB response data.
A path is a full percent-encoded URL path and is most useful when constructing a URL for an HTTP request. It implements neither
Serialize
norDeserialize
.
Remarks
The CouchDB API uses strings for specifying the locations of resources, and
using these strings “in the raw” can be error-prone. The path
module
provides safer alternatives by way of stronger types.
There are two chief kinds of errors that stronger types help eliminate:
Incorrect percent-encoding. For example, document names and attachment names may contain slashes (
/
) and other non-standard characters, and neglect to percent-encode these characters can cause obscure bugs.Type mismatches. For example, mistakenly using a database path to delete a document could cause massive data loss.
Note, however, that the path
module merely makes these types available. It
is up to the application programmer to make use of them.
Example
extern crate couchdb; // Construct view path: '/alpha/_design/bravo/_view/charlie delta': let view_path = couchdb::DatabaseName::new("alpha") .with_design_document_id(couchdb::DesignDocumentName::new("bravo")) .with_view_name("charlie delta"); // Paths are percent-encoded and thus well suited for building URLs. let s = view_path.to_string(); assert_eq!(s, "/alpha/_design/bravo/_view/charlie%20delta"); // Alternatively, paths can be parsed from string. let v2 = couchdb::ViewPath::parse(&s).unwrap(); assert_eq!(view_path, v2);
Structs
AttachmentName |
|
AttachmentPath |
|
DatabaseName |
|
DatabasePath |
|
DesignDocumentId |
|
DesignDocumentName |
|
DesignDocumentPath |
|
DocumentId |
|
DocumentPath |
|
LocalDocumentName |
|
NormalDocumentName |
|
ViewId |
|
ViewName |
|
ViewPath |
|