pub file_label: Option<String>,
pub documents: Vec<String>,
pub vectors: HashSet<ByIdentifier<Vector>>,
- pub attributes: HashSet<ByIdentifier<Attribute>>,
+ pub attributes: HashMap<Identifier, Vec<String>>,
pub mrsets: HashSet<ByIdentifier<MultipleResponseSet>>,
pub variable_sets: HashSet<ByIdentifier<VariableSet>>,
pub encoding: &'static Encoding,
file_label: None,
documents: Vec::new(),
vectors: HashSet::new(),
- attributes: HashSet::new(),
+ attributes: HashMap::new(),
mrsets: HashSet::new(),
variable_sets: HashSet::new(),
encoding,
borrow::Cow,
cell::RefCell,
cmp::Ordering,
- collections::VecDeque,
+ collections::{VecDeque, HashMap},
fmt::{Debug, Display, Formatter, Result as FmtResult},
io::{Error as IoError, Read, Seek, SeekFrom},
iter::repeat,
}),
}
}
+
+
}
// If `s` is valid UTF-8, returns it decoded as UTF-8, otherwise returns it
text: extension.data.into(),
}
}
- fn decode<'a>(&self, decoder: &Decoder) -> Result<Option<Record>, Error> {
+ pub fn decode<'a>(&self, decoder: &Decoder) -> Result<Option<Record>, Error> {
match self.rec_type {
TextRecordType::VariableSets => Ok(Some(Record::VariableSets(
VariableSetRecord::decode(self, decoder),
}
#[derive(Clone, Debug)]
-pub struct AttributeSet(pub Vec<Attribute>);
+pub struct AttributeSet(pub HashMap<Identifier, Vec<String>>);
impl AttributeSet {
fn parse<'a>(
mut input: &'a str,
sentinel: Option<char>,
) -> Result<(AttributeSet, &'a str), Error> {
- let mut attributes = Vec::new();
+ let mut attributes = HashMap::new();
let rest = loop {
match input.chars().next() {
None => break input,
c if c == sentinel => break &input[1..],
_ => {
let (attribute, rest) = Attribute::parse(decoder, input)?;
- attributes.push(attribute);
+ // XXX report duplicate name
+ attributes.insert(attribute.name, attribute.values);
input = rest;
}
}