pub fn discover_document_id(
    docid: &str,
    external_docids: &FstMapCow,
    available_docids: &mut DiscoverIds<'_>,
) -> Result<DocumentId, SerializerError>
{
    if docid.chars().all(|x| x.is_ascii_alphanumeric() || x == '-' || x == '_') {
        match external_docids.get(docid) {
            Some(id) => Ok(DocumentId(id as u32)),
            None => {
                let internal_id = available_docids.next().expect("no more ids available");
                Ok(internal_id)
            },
        }
    } else {
        Err(SerializerError::InvalidDocumentIdFormat)
    }
}
/// Validates a string representation to be a correct document id and returns
/// the corresponding id or generate a new one, this is the way we produce documents ids.
Validates a string representation to be a correct document id and returns
the corresponding id or generate a new one, this is the way we produce documents ids.
Validates a string representation to be a correct document id and returns the corresponding id or generate a new one this is the way we produce documents ids .
pub fn discover_document_id(
    docid: &str,
    external_docids: &FstMapCow,
    available_docids: &mut DiscoverIds<'_>,
) -> Result<DocumentId, SerializerError>
{
    if docid.chars().all(|x| x.is_ascii_alphanumeric() || x == '-' || x == '_') {
        match external_docids.get(docid) {
            Some(id) => Ok(DocumentId(id as u32)),
            None => {
                let internal_id = available_docids.next().expect("no more ids available");
                Ok(internal_id)
            },
        }
    } else {
        Err(SerializerError::InvalidDocumentIdFormat)
    }
}
pub fn discover_document_id ( docid : & str , external_docids : & FstMapCow , available_docids : & mut DiscoverIds < ' _ > , ) -> Result < DocumentId , SerializerError > { if docid . chars ( ) . all ( | x | x . is_ascii_alphanumeric ( ) || x == '-' || x == '_' ) { match external_docids . get ( docid ) { Some ( id ) => Ok ( DocumentId ( id as u32 ) ) , None => { let internal_id = available_docids . next ( ) . expect ( " " ) ; Ok ( internal_id ) } , } } else { Err ( SerializerError :: InvalidDocumentIdFormat ) } }
Validates a string representation to be a correct document id and returns
the corresponding id or generate a new one, this is the way we produce documents ids.
Validates a string representation to be a correct document id and returns the corresponding id or generate a new one this is the way we produce documents ids .
docid
&str
external_docids
&FstMapCow
available_docids
&mut DiscoverIds<'_>
docid
&str
external_docids
&FstMapCow
available_docids
&mut DiscoverIds<'_>