pub fn extract_document_id(primary_key: &str, document: &IndexMap<String, Value>) -> Result<DocumentId, SerializerError> {
    match document.get(primary_key) {
        Some(value) => {
            let string = match value {
                Value::Number(number) => number.to_string(),
                Value::String(string) => string.clone(),
                _ => return Err(SerializerError::InvalidDocumentIdFormat),
            };
            compute_document_id(&string)
        }
        None => Err(SerializerError::DocumentIdNotFound),
    }
}
/// Extracts and validates the document id of a document.
Extracts and validates the document id of a document.
Extracts and validates the document id of a document .
pub fn extract_document_id(primary_key: &str, document: &IndexMap<String, Value>) -> Result<DocumentId, SerializerError> {
    match document.get(primary_key) {
        Some(value) => {
            let string = match value {
                Value::Number(number) => number.to_string(),
                Value::String(string) => string.clone(),
                _ => return Err(SerializerError::InvalidDocumentIdFormat),
            };
            compute_document_id(&string)
        }
        None => Err(SerializerError::DocumentIdNotFound),
    }
}
pub fn extract_document_id ( primary_key : & str , document : & IndexMap < String , Value > ) -> Result < DocumentId , SerializerError > { match document . get ( primary_key ) { Some ( value ) => { let string = match value { Value :: Number ( number ) => number . to_string ( ) , Value :: String ( string ) => string . clone ( ) , _ => return Err ( SerializerError :: InvalidDocumentIdFormat ) , } ; compute_document_id ( & string ) } None => Err ( SerializerError :: DocumentIdNotFound ) , } }
Extracts and validates the document id of a document.
Extracts and validates the document id of a document .
primary_key
&str
document
&IndexMap<String, Value>
primary_key
&str
document
&IndexMap<String, Value>