Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions typesense/src/traits/field_type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::traits::Document;
use std::collections::{BTreeMap, HashMap};
/// Type for a field. Currently it is a wrapping to a `String` but it could be extended to a enum
pub type FieldType = String;
Expand All @@ -8,6 +9,19 @@ pub trait ToTypesenseField {
/// Static function that should implement the types of the typesense documents.
fn to_typesense_type() -> &'static str;
}
/// Generic implementation for any type that is also a Typesense document.
impl<T: Document> ToTypesenseField for T {
fn to_typesense_type() -> &'static str {
"object"
}
}

/// Generic implementation for a Vec of any type that is also a Typesense document.
impl<T: Document> ToTypesenseField for Vec<T> {
fn to_typesense_type() -> &'static str {
"object[]"
}
}

/// macro used internally to add implementations of ToTypesenseField for several rust types.
#[macro_export]
Expand Down
Loading
Loading