Struct aragog::EdgeRecord
source · pub struct EdgeRecord<T> {
pub data: T,
/* private fields */
}
Expand description
Fields§
§data: T
The main document data, must implement Record
.
Note: The data is flattened on save, so you won’t have any field named data
in your database.
Implementations§
source§impl<T: Record> EdgeRecord<T>
impl<T: Record> EdgeRecord<T>
sourcepub async fn from_record<D, R>(
&self,
db_access: &D
) -> Result<DatabaseRecord<R>, Error>where
D: DatabaseAccess + ?Sized,
R: Record,
pub async fn from_record<D, R>( &self, db_access: &D ) -> Result<DatabaseRecord<R>, Error>where D: DatabaseAccess + ?Sized, R: Record,
Retrieves the from
document from the database
sourcepub async fn to_record<D, R>(
&self,
db_access: &D
) -> Result<DatabaseRecord<R>, Error>where
D: DatabaseAccess + ?Sized,
R: Record,
pub async fn to_record<D, R>( &self, db_access: &D ) -> Result<DatabaseRecord<R>, Error>where D: DatabaseAccess + ?Sized, R: Record,
Retrieves the to
document from the database
sourcepub fn id_from(&self) -> &String
pub fn id_from(&self) -> &String
Retrieves the document _from
field, storing the target documents id
.
sourcepub fn id_to(&self) -> &String
pub fn id_to(&self) -> &String
Retrieves the document _to
field, storing the target documents id
.
sourcepub fn key_from(&self) -> &str
pub fn key_from(&self) -> &str
Parses the from
value to retrieve only the _key
part.
Panics
This method may panic if the from
value is not formatted correctly.
sourcepub fn key_to(&self) -> &str
pub fn key_to(&self) -> &str
Parses the to
value to retrieve only the _key
part.
Panics
This method may panic if the to
value is not formatted correctly.
sourcepub fn to_collection_name(&self) -> String
pub fn to_collection_name(&self) -> String
Parses the from
value to retrieve only the collection name part.
Panics
This method may panic if the to
value is not formatted correctly.
sourcepub fn from_collection_name(&self) -> &str
pub fn from_collection_name(&self) -> &str
Parses the to
value to retrieve only the collection name part.
Panics
This method may panic if the from
value is not formatted correctly.
Trait Implementations§
source§impl<T: Clone> Clone for EdgeRecord<T>
impl<T: Clone> Clone for EdgeRecord<T>
source§fn clone(&self) -> EdgeRecord<T>
fn clone(&self) -> EdgeRecord<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Record> Deref for EdgeRecord<T>
impl<T: Record> Deref for EdgeRecord<T>
source§impl<T: Record> DerefMut for EdgeRecord<T>
impl<T: Record> DerefMut for EdgeRecord<T>
source§impl<'de, T> Deserialize<'de> for EdgeRecord<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for EdgeRecord<T>where T: Deserialize<'de>,
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>,
source§impl<T: Record + Send> Record for EdgeRecord<T>
impl<T: Record + Send> Record for EdgeRecord<T>
source§const COLLECTION_NAME: &'static str = T::COLLECTION_NAME
const COLLECTION_NAME: &'static str = T::COLLECTION_NAME
source§fn before_create_hook<'life0, 'life1, 'async_trait, D>(
&'life0 mut self,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_create_hook<'life0, 'life1, 'async_trait, D>( &'life0 mut self, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
source§fn before_save_hook<'life0, 'life1, 'async_trait, D>(
&'life0 mut self,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_save_hook<'life0, 'life1, 'async_trait, D>( &'life0 mut self, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
source§fn before_delete_hook<'life0, 'life1, 'async_trait, D>(
&'life0 mut self,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn before_delete_hook<'life0, 'life1, 'async_trait, D>( &'life0 mut self, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
source§fn after_create_hook<'life0, 'life1, 'async_trait, D>(
&'life0 mut self,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_create_hook<'life0, 'life1, 'async_trait, D>( &'life0 mut self, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
source§fn after_save_hook<'life0, 'life1, 'async_trait, D>(
&'life0 mut self,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_save_hook<'life0, 'life1, 'async_trait, D>( &'life0 mut self, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
source§fn after_delete_hook<'life0, 'life1, 'async_trait, D>(
&'life0 mut self,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn after_delete_hook<'life0, 'life1, 'async_trait, D>( &'life0 mut self, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
source§fn find<'life0, 'life1, 'async_trait, D>(
key: &'life0 str,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<DatabaseRecord<Self>, Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find<'life0, 'life1, 'async_trait, D>( key: &'life0 str, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = Result<DatabaseRecord<Self>, Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
source§fn get<'life0, 'life1, 'async_trait, D>(
query: &'life0 Query,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<QueryResult<Self>, Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait, D>( query: &'life0 Query, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = Result<QueryResult<Self>, Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
source§fn get_in_batches<'life0, 'life1, 'async_trait, D>(
query: &'life0 Query,
db_accessor: &'life1 D,
batch_size: u32
) -> Pin<Box<dyn Future<Output = Result<QueryCursor<Self>, Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_in_batches<'life0, 'life1, 'async_trait, D>( query: &'life0 Query, db_accessor: &'life1 D, batch_size: u32 ) -> Pin<Box<dyn Future<Output = Result<QueryCursor<Self>, Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Query
in batches.
Simple wrapper for DatabaseRecord
<T
>::get_in_batches
source§fn exists<'life0, 'life1, 'async_trait, D>(
query: &'life0 Query,
db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: Send + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exists<'life0, 'life1, 'async_trait, D>( query: &'life0 Query, db_accessor: &'life1 D ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Query
.
Simple wrapper for DatabaseRecord
<T
>::exists
source§fn create<'life0, 'async_trait, D>(
record: Self,
db_accessor: &'life0 D
) -> Pin<Box<dyn Future<Output = Result<DatabaseRecord<Self>, Error>> + Send + 'async_trait>>where
D: DatabaseAccess + ?Sized + 'async_trait,
Self: Send + 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait, D>( record: Self, db_accessor: &'life0 D ) -> Pin<Box<dyn Future<Output = Result<DatabaseRecord<Self>, Error>> + Send + 'async_trait>>where D: DatabaseAccess + ?Sized + 'async_trait, Self: Send + 'async_trait, 'life0: 'async_trait,
source§fn transaction_builder() -> TransactionBuilder
fn transaction_builder() -> TransactionBuilder
source§fn transaction<'life0, 'async_trait>(
db_connection: &'life0 DatabaseConnection
) -> Pin<Box<dyn Future<Output = Result<Transaction, Error>> + Send + 'async_trait>>where
Self: Send + 'async_trait,
'life0: 'async_trait,
fn transaction<'life0, 'async_trait>( db_connection: &'life0 DatabaseConnection ) -> Pin<Box<dyn Future<Output = Result<Transaction, Error>> + Send + 'async_trait>>where Self: Send + 'async_trait, 'life0: 'async_trait,
source§impl<T> Serialize for EdgeRecord<T>where
T: Serialize,
impl<T> Serialize for EdgeRecord<T>where T: Serialize,
source§impl<T: Record> Validate for EdgeRecord<T>
impl<T: Record> Validate for EdgeRecord<T>
source§fn validations(&self, errors: &mut Vec<String>)
fn validations(&self, errors: &mut Vec<String>)
errors
string vector with custom error messagessource§fn validate(&self) -> Result<(), Error>
fn validate(&self) -> Result<(), Error>
source§fn is_valid(&self) -> bool
fn is_valid(&self) -> bool
false
if they failed, on success true
is returnedsource§fn validate_field_presence<T>(
field_name: &str,
field: &Option<T>,
errors: &mut Vec<String>
) -> bool
fn validate_field_presence<T>( field_name: &str, field: &Option<T>, errors: &mut Vec<String> ) -> bool
validations
method since it will fill the errors
with a message if the field
is missing. Read moresource§fn validate_field_absence<T>(
field_name: &str,
field: &Option<T>,
errors: &mut Vec<String>
) -> bool
fn validate_field_absence<T>( field_name: &str, field: &Option<T>, errors: &mut Vec<String> ) -> bool
validations
method since it will fill the errors
with a message if the field
is missing. Read moresource§fn validate_max_len(
field_path: &str,
str: &str,
max_len: usize,
errors: &mut Vec<String>
) -> bool
fn validate_max_len( field_path: &str, str: &str, max_len: usize, errors: &mut Vec<String> ) -> bool
source§fn validate_min_len(
field_path: &str,
str: &str,
min_len: usize,
errors: &mut Vec<String>
) -> bool
fn validate_min_len( field_path: &str, str: &str, min_len: usize, errors: &mut Vec<String> ) -> bool
source§fn validate_max_count<T>(
field_path: &str,
field_value: Iter<'_, T>,
max_count: usize,
errors: &mut Vec<String>
) -> bool
fn validate_max_count<T>( field_path: &str, field_value: Iter<'_, T>, max_count: usize, errors: &mut Vec<String> ) -> bool
source§fn validate_min_count<T>(
field_path: &str,
field_value: Iter<'_, T>,
min_count: usize,
errors: &mut Vec<String>
) -> bool
fn validate_min_count<T>( field_path: &str, field_value: Iter<'_, T>, min_count: usize, errors: &mut Vec<String> ) -> bool
source§fn validate_count<T>(
field_path: &str,
field_value: Iter<'_, T>,
count: usize,
errors: &mut Vec<String>
) -> bool
fn validate_count<T>( field_path: &str, field_value: Iter<'_, T>, count: usize, errors: &mut Vec<String> ) -> bool
source§fn validate_regex(
field_path: &str,
str: &str,
regex: &str,
errors: &mut Vec<String>
) -> bool
fn validate_regex( field_path: &str, str: &str, regex: &str, errors: &mut Vec<String> ) -> bool
source§fn validate_greater_than<T: PartialOrd + Display>(
field_path: &str,
value: T,
min_value: T,
errors: &mut Vec<String>
) -> bool
fn validate_greater_than<T: PartialOrd + Display>( field_path: &str, value: T, min_value: T, errors: &mut Vec<String> ) -> bool
source§fn validate_greater_or_equal_to<T: PartialOrd + Display>(
field_path: &str,
value: T,
min_value: T,
errors: &mut Vec<String>
) -> bool
fn validate_greater_or_equal_to<T: PartialOrd + Display>( field_path: &str, value: T, min_value: T, errors: &mut Vec<String> ) -> bool
source§fn validate_lesser_than<T: PartialOrd + Display>(
field_path: &str,
value: T,
max_value: T,
errors: &mut Vec<String>
) -> bool
fn validate_lesser_than<T: PartialOrd + Display>( field_path: &str, value: T, max_value: T, errors: &mut Vec<String> ) -> bool
source§fn validate_lesser_or_equal_to<T: PartialOrd + Display>(
field_path: &str,
value: T,
max_value: T,
errors: &mut Vec<String>
) -> bool
fn validate_lesser_or_equal_to<T: PartialOrd + Display>( field_path: &str, value: T, max_value: T, errors: &mut Vec<String> ) -> bool
source§const SIMPLE_EMAIL_REGEX: &'static str = r#"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}"#
const SIMPLE_EMAIL_REGEX: &'static str = r#"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}"#
source§const RFC_5322_EMAIL_REGEX: &'static str = r#"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"#
const RFC_5322_EMAIL_REGEX: &'static str = r#"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"#
simple_email_regex