pub struct RootDocumentName { /* private fields */ }
Expand description
A root document name.
§Format
{database_name}/documents
§Examples
use firestore_path::RootDocumentName;
use std::str::FromStr;
let root_document_name = RootDocumentName::from_str(
"projects/my-project/databases/my-database/documents"
)?;
assert_eq!(
root_document_name.to_string(),
"projects/my-project/databases/my-database/documents"
);
Implementations§
Source§impl RootDocumentName
impl RootDocumentName
Sourcepub fn new(database_name: DatabaseName) -> Self
pub fn new(database_name: DatabaseName) -> Self
Creates a new RootDocumentName
.
§Examples
use firestore_path::{DatabaseName,RootDocumentName};
use std::str::FromStr;
let database_name = DatabaseName::from_str(
"projects/my-project/databases/my-database"
)?;
assert_eq!(
RootDocumentName::new(database_name),
RootDocumentName::from_str(
"projects/my-project/databases/my-database/documents"
)?
);
Sourcepub fn collection<E, T>(
&self,
collection_path: T,
) -> Result<CollectionName, Error>
pub fn collection<E, T>( &self, collection_path: T, ) -> Result<CollectionName, Error>
Creates a new CollectionName
from this RootDocumentName
and collection_path
.
§Examples
use firestore_path::{CollectionId,CollectionName,CollectionPath,RootDocumentName};
use std::str::FromStr;
let root_document_name = RootDocumentName::from_str(
"projects/my-project/databases/my-database/documents"
)?;
assert_eq!(
root_document_name.collection("chatrooms")?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms"
)?
);
assert_eq!(
root_document_name.collection("chatrooms/chatroom1/messages")?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages"
)?
);
assert_eq!(
root_document_name.collection(CollectionId::from_str("chatrooms")?)?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms"
)?
);
assert_eq!(
root_document_name.collection(CollectionPath::from_str("chatrooms/chatroom1/messages")?)?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages"
)?
);
Sourcepub fn into_collection<E, T>(
self,
collection_path: T,
) -> Result<CollectionName, Error>
pub fn into_collection<E, T>( self, collection_path: T, ) -> Result<CollectionName, Error>
Creates a new CollectionName
by consuming RootDocumentName
with the provided collection_path
.
§Examples
use firestore_path::{CollectionId,CollectionName,CollectionPath,RootDocumentName};
use std::str::FromStr;
let root_document_name = RootDocumentName::from_str(
"projects/my-project/databases/my-database/documents"
)?;
assert_eq!(
root_document_name.clone().into_collection("chatrooms")?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms"
)?
);
assert_eq!(
root_document_name.clone().into_collection("chatrooms/chatroom1/messages")?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages"
)?
);
assert_eq!(
root_document_name.clone().into_collection(CollectionId::from_str("chatrooms")?)?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms"
)?
);
assert_eq!(
root_document_name.into_collection(CollectionPath::from_str("chatrooms/chatroom1/messages")?)?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages"
)?
);
Sourcepub fn doc<E, T>(&self, document_path: T) -> Result<DocumentName, Error>
pub fn doc<E, T>(&self, document_path: T) -> Result<DocumentName, Error>
Creates a new DocumentName
from this RootDocumentName
and document_path
.
§Examples
use firestore_path::{DocumentName,DocumentPath,RootDocumentName};
use std::str::FromStr;
let root_document_name = RootDocumentName::from_str(
"projects/my-project/databases/my-database/documents"
)?;
assert_eq!(
root_document_name.doc("chatrooms/chatroom1")?,
DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?
);
assert_eq!(
root_document_name.doc("chatrooms/chatroom1/messages/message1")?,
DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages/message1"
)?
);
assert_eq!(
root_document_name.doc(DocumentPath::from_str("chatrooms/chatroom1")?)?,
DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?
);
assert_eq!(
root_document_name.doc(DocumentPath::from_str("chatrooms/chatroom1/messages/message1")?)?,
DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages/message1"
)?
);
Sourcepub fn into_doc<E, T>(self, document_path: T) -> Result<DocumentName, Error>
pub fn into_doc<E, T>(self, document_path: T) -> Result<DocumentName, Error>
Creates a new DocumentName
by consuming the RootDocumentName
with the provided document_path
.
§Examples
use firestore_path::{DocumentName,DocumentPath,RootDocumentName};
use std::str::FromStr;
let root_document_name = RootDocumentName::from_str(
"projects/my-project/databases/my-database/documents"
)?;
assert_eq!(
root_document_name.clone().into_doc("chatrooms/chatroom1")?,
DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?
);
assert_eq!(
root_document_name.clone().into_doc("chatrooms/chatroom1/messages/message1")?,
DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages/message1"
)?
);
assert_eq!(
root_document_name.clone().into_doc(DocumentPath::from_str("chatrooms/chatroom1")?)?,
DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?
);
assert_eq!(
root_document_name.doc(DocumentPath::from_str("chatrooms/chatroom1/messages/message1")?)?,
DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages/message1"
)?
);
Trait Implementations§
Source§impl Clone for RootDocumentName
impl Clone for RootDocumentName
Source§fn clone(&self) -> RootDocumentName
fn clone(&self) -> RootDocumentName
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 RootDocumentName
impl Debug for RootDocumentName
Source§impl Display for RootDocumentName
impl Display for RootDocumentName
Source§impl From<DatabaseName> for RootDocumentName
impl From<DatabaseName> for RootDocumentName
Source§fn from(database_name: DatabaseName) -> Self
fn from(database_name: DatabaseName) -> Self
Converts to this type from the input type.
Source§impl From<RootDocumentName> for DatabaseName
impl From<RootDocumentName> for DatabaseName
Source§fn from(root_document_name: RootDocumentName) -> Self
fn from(root_document_name: RootDocumentName) -> Self
Converts to this type from the input type.
Source§impl FromStr for RootDocumentName
impl FromStr for RootDocumentName
Source§impl Hash for RootDocumentName
impl Hash for RootDocumentName
Source§impl Ord for RootDocumentName
impl Ord for RootDocumentName
Source§fn cmp(&self, other: &RootDocumentName) -> Ordering
fn cmp(&self, other: &RootDocumentName) -> 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 RootDocumentName
impl PartialEq for RootDocumentName
Source§impl PartialOrd for RootDocumentName
impl PartialOrd for RootDocumentName
Source§impl TryFrom<&str> for RootDocumentName
impl TryFrom<&str> for RootDocumentName
Source§impl TryFrom<String> for RootDocumentName
impl TryFrom<String> for RootDocumentName
impl Eq for RootDocumentName
impl StructuralPartialEq for RootDocumentName
Auto Trait Implementations§
impl Freeze for RootDocumentName
impl RefUnwindSafe for RootDocumentName
impl Send for RootDocumentName
impl Sync for RootDocumentName
impl Unpin for RootDocumentName
impl UnwindSafe for RootDocumentName
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