uniprot 0.7.0

Rust data structures and parser for the Uniprot database(s).
Documentation
use std::borrow::Cow;
use std::io::BufRead;

use quick_xml::events::BytesStart;
use quick_xml::Reader;

use crate::common::ShortString;
use crate::error::Error;
use crate::parser::utils::extract_attribute;
use crate::parser::FromXml;

#[derive(Debug, Clone)]
pub struct InterproReference {
    pub name: ShortString,
    pub id: ShortString,
}

impl FromXml for InterproReference {
    fn from_xml<B: BufRead>(
        event: &BytesStart,
        reader: &mut Reader<B>,
        buffer: &mut Vec<u8>,
    ) -> Result<Self, Error> {
        debug_assert_eq!(event.local_name().as_ref(), b"ipr");

        let name = extract_attribute(event, "name")?
            .ok_or(Error::MissingAttribute("name", "signatureSequenceMatch"))?
            .decode_and_unescape_value(reader)
            .map(ShortString::from)?;
        let id = extract_attribute(event, "id")?
            .ok_or(Error::MissingAttribute("id", "signatureSequenceMatch"))?
            .decode_and_unescape_value(reader)
            .map(ShortString::from)?;

        reader.read_to_end_into(event.name(), buffer)?;
        Ok(InterproReference { name, id })
    }
}