use std::{fs::File, io::{BufRead, BufReader}};
use super::{{super::super::Error}, *};

pub fn read(file: File) -> Result<Vec<Specifier>, Error> {
    let mut specifiers  = Vec::new();
    let     file_buffer = BufReader::new(file);    

    for line in file_buffer.lines() {
        let line = line?;
        if let Some(specifier) = Specifier::parse_line(line.as_ref()) {
            specifiers.push(specifier);
        }

        else {
            return Err(Error::IncorrectCUELine(line));
        }
    }

    Ok(specifiers)
}