pub struct DocumentPath { /* private fields */ }
Expand description
Implementations§
Source§impl DocumentPath
impl DocumentPath
Sourcepub fn new(collection_path: CollectionPath, document_id: DocumentId) -> Self
pub fn new(collection_path: CollectionPath, document_id: DocumentId) -> Self
Creates a new DocumentPath
.
§Examples
use firestore_path::{CollectionPath,DocumentId,DocumentPath};
use std::str::FromStr;
let collection_path = CollectionPath::from_str("chatrooms")?;
let document_id = DocumentId::from_str("chatroom1")?;
let document_path = DocumentPath::new(collection_path, document_id);
assert_eq!(document_path.to_string(), "chatrooms/chatroom1");
Sourcepub fn collection<E, T>(
&self,
collection_path: T,
) -> Result<CollectionPath, Error>
pub fn collection<E, T>( &self, collection_path: T, ) -> Result<CollectionPath, Error>
Creates a new CollectionPath
from this DocumentPath
and collection_path
.
§Examples
use firestore_path::{CollectionId,CollectionPath,DocumentPath};
use std::str::FromStr;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
assert_eq!(
document_path.collection("messages")?,
CollectionPath::from_str("chatrooms/chatroom1/messages")?
);
assert_eq!(
document_path.collection("messages/message1/col")?,
CollectionPath::from_str("chatrooms/chatroom1/messages/message1/col")?
);
assert_eq!(
document_path.collection(CollectionId::from_str("messages")?)?,
CollectionPath::from_str("chatrooms/chatroom1/messages")?
);
assert_eq!(
document_path.collection(CollectionPath::from_str("messages/message1/col")?)?,
CollectionPath::from_str("chatrooms/chatroom1/messages/message1/col")?
);
Sourcepub fn doc<E, T>(&self, document_path: T) -> Result<DocumentPath, Error>
pub fn doc<E, T>(&self, document_path: T) -> Result<DocumentPath, Error>
Creates a new DocumentPath
from this DocumentPath
and document_path
.
§Examples
use firestore_path::{CollectionPath,DocumentPath};
use std::str::FromStr;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
assert_eq!(
document_path.doc("messages/message1")?,
DocumentPath::from_str("chatrooms/chatroom1/messages/message1")?
);
assert_eq!(
document_path.doc("messages/message1/col/doc")?,
DocumentPath::from_str("chatrooms/chatroom1/messages/message1/col/doc")?
);
assert_eq!(
document_path.doc(DocumentPath::from_str("messages/message1")?)?,
DocumentPath::from_str("chatrooms/chatroom1/messages/message1")?
);
assert_eq!(
document_path.doc(DocumentPath::from_str("messages/message1/col/doc")?)?,
DocumentPath::from_str("chatrooms/chatroom1/messages/message1/col/doc")?
);
Sourcepub fn collection_id(&self) -> &CollectionId
pub fn collection_id(&self) -> &CollectionId
Returns the CollectionId
of this DocumentPath
.
§Examples
use firestore_path::{CollectionId,DocumentPath};
use std::str::FromStr;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
assert_eq!(
document_path.collection_id(),
&CollectionId::from_str("chatrooms")?
);
Sourcepub fn document_id(&self) -> &DocumentId
pub fn document_id(&self) -> &DocumentId
Returns the DocumentId
of this DocumentPath
.
§Examples
use firestore_path::{DocumentId,DocumentPath};
use std::str::FromStr;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
assert_eq!(
document_path.document_id(),
&DocumentId::from_str("chatroom1")?
);
Sourcepub fn into_collection<E, T>(
self,
collection_path: T,
) -> Result<CollectionPath, Error>
pub fn into_collection<E, T>( self, collection_path: T, ) -> Result<CollectionPath, Error>
Creates a new CollectionPath
by consuming the DocumentPath
with the provided collection_path
.
§Examples
use firestore_path::{CollectionId,CollectionPath,DocumentPath};
use std::str::FromStr;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
assert_eq!(
document_path.clone().into_collection("messages")?,
CollectionPath::from_str("chatrooms/chatroom1/messages")?
);
assert_eq!(
document_path.clone().into_collection("messages/message1/col")?,
CollectionPath::from_str("chatrooms/chatroom1/messages/message1/col")?
);
assert_eq!(
document_path.clone().into_collection(CollectionId::from_str("messages")?)?,
CollectionPath::from_str("chatrooms/chatroom1/messages")?
);
assert_eq!(
document_path.into_collection(CollectionPath::from_str("messages/message1/col")?)?,
CollectionPath::from_str("chatrooms/chatroom1/messages/message1/col")?
);
Sourcepub fn into_doc<E, T>(self, document_path: T) -> Result<DocumentPath, Error>
pub fn into_doc<E, T>(self, document_path: T) -> Result<DocumentPath, Error>
Creates a new DocumentPath
by consuming the DocumentPath
with the provided document_path
.
§Examples
use firestore_path::{CollectionPath,DocumentPath};
use std::str::FromStr;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
assert_eq!(
document_path.clone().into_doc("messages/message1")?,
DocumentPath::from_str("chatrooms/chatroom1/messages/message1")?
);
assert_eq!(
document_path.clone().into_doc("messages/message1/col/doc")?,
DocumentPath::from_str("chatrooms/chatroom1/messages/message1/col/doc")?
);
assert_eq!(
document_path.clone().into_doc(DocumentPath::from_str("messages/message1")?)?,
DocumentPath::from_str("chatrooms/chatroom1/messages/message1")?
);
assert_eq!(
document_path.into_doc(DocumentPath::from_str("messages/message1/col/doc")?)?,
DocumentPath::from_str("chatrooms/chatroom1/messages/message1/col/doc")?
);
Sourcepub fn into_parent(self) -> CollectionPath
pub fn into_parent(self) -> CollectionPath
Consumes the DocumentPath
, returning the parent CollectionPath
.
§Examples
use firestore_path::{CollectionPath,DocumentPath};
use std::str::FromStr;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
assert_eq!(
document_path.clone().into_parent(),
CollectionPath::from_str("chatrooms")?
);
assert_eq!(
document_path.into_parent(),
CollectionPath::from_str("chatrooms")?
);
Sourcepub fn parent(&self) -> &CollectionPath
pub fn parent(&self) -> &CollectionPath
Returns the parent CollectionPath
of this DocumentPath
.
§Examples
use firestore_path::{CollectionPath,DocumentPath};
use std::str::FromStr;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
assert_eq!(
document_path.parent(),
&CollectionPath::from_str("chatrooms")?
);
Trait Implementations§
Source§impl Clone for DocumentPath
impl Clone for DocumentPath
Source§fn clone(&self) -> DocumentPath
fn clone(&self) -> DocumentPath
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for DocumentPath
impl Debug for DocumentPath
Source§impl Display for DocumentPath
impl Display for DocumentPath
Source§impl From<DocumentName> for DocumentPath
impl From<DocumentName> for DocumentPath
Source§fn from(document_name: DocumentName) -> Self
fn from(document_name: DocumentName) -> Self
Converts to this type from the input type.
Source§impl From<DocumentPath> for CollectionPath
impl From<DocumentPath> for CollectionPath
Source§fn from(document_path: DocumentPath) -> Self
fn from(document_path: DocumentPath) -> Self
Converts to this type from the input type.
Source§impl From<DocumentPath> for DocumentId
impl From<DocumentPath> for DocumentId
Source§fn from(document_path: DocumentPath) -> Self
fn from(document_path: DocumentPath) -> Self
Converts to this type from the input type.
Source§impl FromStr for DocumentPath
impl FromStr for DocumentPath
Source§impl Hash for DocumentPath
impl Hash for DocumentPath
Source§impl Ord for DocumentPath
impl Ord for DocumentPath
Source§fn cmp(&self, other: &DocumentPath) -> Ordering
fn cmp(&self, other: &DocumentPath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for DocumentPath
impl PartialEq for DocumentPath
Source§impl PartialOrd for DocumentPath
impl PartialOrd for DocumentPath
Source§impl TryFrom<&str> for DocumentPath
impl TryFrom<&str> for DocumentPath
Source§impl TryFrom<String> for DocumentPath
impl TryFrom<String> for DocumentPath
impl Eq for DocumentPath
impl StructuralPartialEq for DocumentPath
Auto Trait Implementations§
impl Freeze for DocumentPath
impl RefUnwindSafe for DocumentPath
impl Send for DocumentPath
impl Sync for DocumentPath
impl Unpin for DocumentPath
impl UnwindSafe for DocumentPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more