/// Validates a string representation to be a correct document id and
/// returns the hash of the given type, this is the way we produce documents ids.
Validates a string representation to be a correct document id and
returns the hash of the given type, this is the way we produce documents ids.
Validates a string representation to be a correct document id and returns the hash of the given type this is the way we produce documents ids .
pub fn compute_document_id(string: &str) -> Result<DocumentId, SerializerError> {
    if string.chars().all(|x| x.is_ascii_alphanumeric() || x == '-' || x == '_') {
        let mut s = SipHasher::new();
        string.hash(&mut s);
        Ok(DocumentId(s.finish()))
    } else {
        Err(SerializerError::InvalidDocumentIdFormat)
    }
}
pub fn compute_document_id ( string : & str ) -> Result < DocumentId , SerializerError > { if string . chars ( ) . all ( | x | x . is_ascii_alphanumeric ( ) || x == '-' || x == '_' ) { let mut s = SipHasher :: new ( ) ; string . hash ( & mut s ) ; Ok ( DocumentId ( s . finish ( ) ) ) } else { Err ( SerializerError :: InvalidDocumentIdFormat ) } }
Validates a string representation to be a correct document id and
returns the hash of the given type, this is the way we produce documents ids.
Validates a string representation to be a correct document id and returns the hash of the given type this is the way we produce documents ids .
string
&str