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