pub struct DocumentCollection {
pub documents: Vec<Document>,
pub metadata: HashMap<String, Value>,
}
Expand description
A collection of documents
Fields§
§documents: Vec<Document>
The documents in the collection
metadata: HashMap<String, Value>
Metadata about the collection
Implementations§
Source§impl DocumentCollection
impl DocumentCollection
Sourcepub fn new_with_documents(documents: Vec<Document>) -> Self
pub fn new_with_documents(documents: Vec<Document>) -> Self
Create a new document collection with documents
Sourcepub fn add_document(&mut self, document: Document)
pub fn add_document(&mut self, document: Document)
Add a document to the collection
Sourcepub fn add_documents(&mut self, documents: Vec<Document>)
pub fn add_documents(&mut self, documents: Vec<Document>)
Add multiple documents to the collection
Sourcepub fn total_length(&self) -> usize
pub fn total_length(&self) -> usize
Get the total length of all documents
Sourcepub fn split_all(&self, chunk_size: usize, overlap: usize) -> DocumentCollection
pub fn split_all(&self, chunk_size: usize, overlap: usize) -> DocumentCollection
Split all documents into chunks
Sourcepub fn filter<F>(&self, predicate: F) -> DocumentCollection
pub fn filter<F>(&self, predicate: F) -> DocumentCollection
Filter documents based on a predicate
Trait Implementations§
Source§impl Clone for DocumentCollection
impl Clone for DocumentCollection
Source§fn clone(&self) -> DocumentCollection
fn clone(&self) -> DocumentCollection
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 DocumentCollection
impl Debug for DocumentCollection
Source§impl Default for DocumentCollection
impl Default for DocumentCollection
Source§impl<'de> Deserialize<'de> for DocumentCollection
impl<'de> Deserialize<'de> for DocumentCollection
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for DocumentCollection
impl PartialEq for DocumentCollection
Source§impl Serializable for DocumentCollection
impl Serializable for DocumentCollection
Source§fn is_serializable() -> bool
fn is_serializable() -> bool
Check if this object is serializable Read more
Source§fn to_json_pretty(&self) -> Result<String>
fn to_json_pretty(&self) -> Result<String>
Serialize this object to a pretty-printed JSON string
Source§fn to_dict(&self) -> Result<HashMap<String, Value>>
fn to_dict(&self) -> Result<HashMap<String, Value>>
Serialize this object to a dictionary (HashMap)
Source§impl Serialize for DocumentCollection
impl Serialize for DocumentCollection
impl StructuralPartialEq for DocumentCollection
Auto Trait Implementations§
impl Freeze for DocumentCollection
impl RefUnwindSafe for DocumentCollection
impl Send for DocumentCollection
impl Sync for DocumentCollection
impl Unpin for DocumentCollection
impl UnwindSafe for DocumentCollection
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