Struct firestore_path::DocumentName
source · pub struct DocumentName { /* private fields */ }
Expand description
A document name.
Format
{database_name}/{document_path}
Examples
use firestore_path::DocumentName;
use std::str::FromStr;
let document_name = DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?;
assert_eq!(
document_name.to_string(),
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
);
Implementations§
source§impl DocumentName
impl DocumentName
sourcepub fn new(database_name: DatabaseName, document_path: DocumentPath) -> Self
pub fn new(database_name: DatabaseName, document_path: DocumentPath) -> Self
Creates a new DocumentName
.
Examples
use firestore_path::{DatabaseName,DocumentName,DocumentPath};
use std::str::FromStr;
let database_name = DatabaseName::from_str("projects/my-project/databases/my-database/documents")?;
let document_path = DocumentPath::from_str("chatrooms/chatroom1")?;
let document_name = DocumentName::new(database_name, document_path);
assert_eq!(
document_name.to_string(),
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
);
sourcepub fn collection<E, T>(self, collection_id: T) -> Result<CollectionName, Error>
pub fn collection<E, T>(self, collection_id: T) -> Result<CollectionName, Error>
Creates a new CollectionName
from this DocumentName
and collection_id
.
Examples
use firestore_path::{CollectionName,DocumentName};
use std::str::FromStr;
let document_name = DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?;
assert_eq!(
document_name.collection("messages")?,
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1/messages"
)?
);
sourcepub fn database_name(&self) -> &DatabaseName
pub fn database_name(&self) -> &DatabaseName
Returns the DatabaseName
of this DocumentName
.
Examples
use firestore_path::{DatabaseName,DocumentName};
use std::str::FromStr;
let document_name = DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?;
assert_eq!(
document_name.database_name(),
&DatabaseName::from_str("projects/my-project/databases/my-database/documents")?
);
sourcepub fn document_id(&self) -> &DocumentId
pub fn document_id(&self) -> &DocumentId
Returns the DocumentId
of this DocumentName
.
Examples
use firestore_path::{DocumentId,DocumentName};
use std::str::FromStr;
let document_name = DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?;
assert_eq!(document_name.document_id(), &DocumentId::from_str("chatroom1")?);
sourcepub fn parent(self) -> CollectionName
pub fn parent(self) -> CollectionName
Returns the parent CollectionName
of this DocumentName
.
Examples
use firestore_path::{CollectionName,DocumentName};
use std::str::FromStr;
let document_name = DocumentName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms/chatroom1"
)?;
assert_eq!(
document_name.parent(),
CollectionName::from_str(
"projects/my-project/databases/my-database/documents/chatrooms"
)?
);
Trait Implementations§
source§impl Clone for DocumentName
impl Clone for DocumentName
source§fn clone(&self) -> DocumentName
fn clone(&self) -> DocumentName
Returns a copy 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 DocumentName
impl Debug for DocumentName
source§impl Display for DocumentName
impl Display for DocumentName
source§impl From<DocumentName> for DatabaseName
impl From<DocumentName> for DatabaseName
source§fn from(document_name: DocumentName) -> Self
fn from(document_name: DocumentName) -> Self
Converts to this type from the input type.
source§impl From<DocumentName> for DocumentId
impl From<DocumentName> for DocumentId
source§fn from(document_name: DocumentName) -> Self
fn from(document_name: DocumentName) -> Self
Converts to this type from the input type.
source§impl FromStr for DocumentName
impl FromStr for DocumentName
source§impl Hash for DocumentName
impl Hash for DocumentName
source§impl Ord for DocumentName
impl Ord for DocumentName
source§fn cmp(&self, other: &DocumentName) -> Ordering
fn cmp(&self, other: &DocumentName) -> 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 DocumentName
impl PartialEq for DocumentName
source§fn eq(&self, other: &DocumentName) -> bool
fn eq(&self, other: &DocumentName) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for DocumentName
impl PartialOrd for DocumentName
source§fn partial_cmp(&self, other: &DocumentName) -> Option<Ordering>
fn partial_cmp(&self, other: &DocumentName) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<&str> for DocumentName
impl TryFrom<&str> for DocumentName
source§impl TryFrom<String> for DocumentName
impl TryFrom<String> for DocumentName
impl Eq for DocumentName
impl StructuralEq for DocumentName
impl StructuralPartialEq for DocumentName
Auto Trait Implementations§
impl RefUnwindSafe for DocumentName
impl Send for DocumentName
impl Sync for DocumentName
impl Unpin for DocumentName
impl UnwindSafe for DocumentName
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