use std::borrow::Cow;
use hashbrown::HashMap;
#[derive(Debug, Clone, Copy)]
pub enum AttributeType {
Integer,
String,
}
#[derive(Debug)]
pub(crate) struct AttributeDefinition {
pub(crate) name: String,
pub(crate) attribute_type: AttributeType,
pub(crate) required: bool,
}
#[derive(Debug)]
pub(crate) enum AttributeValue<'a> {
Integer(i64),
String(Cow<'a, [u8]>),
}
lazy_static! {
pub(crate) static ref EMPTY_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> =
HashMap::new();
pub(crate) static ref LIST_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"count".as_bytes(),
AttributeDefinition {
name: "count".to_string(),
attribute_type: AttributeType::Integer,
required: true,
},
);
map
};
pub(crate) static ref SPECTRUM_LIST_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"count".as_bytes(),
AttributeDefinition {
name: "count".to_string(),
attribute_type: AttributeType::Integer,
required: true,
},
);
map.insert(
"defaultDataProcessingRef".as_bytes(),
AttributeDefinition {
name: "defaultDataProcessingRef".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map
};
pub(crate) static ref ID_ATTRIBUTE: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"id".as_bytes(),
AttributeDefinition {
name: "id".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map
};
pub(crate) static ref REF_ATTRIBUTE: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"ref".as_bytes(),
AttributeDefinition {
name: "ref".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map
};
pub(crate) static ref RUN_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"id".as_bytes(),
AttributeDefinition {
name: "id".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map.insert(
"defaultInstrumentConfigurationRef".as_bytes(),
AttributeDefinition {
name: "defaultInstrumentConfigurationRef".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map.insert(
"defaultSourceFileRef".as_bytes(),
AttributeDefinition {
name: "defaultSourceFileRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"sampleRef".as_bytes(),
AttributeDefinition {
name: "sampleRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"startTimeStamp".as_bytes(),
AttributeDefinition {
name: "startTimeStamp".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map
};
pub(crate) static ref SPECTRUM_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"id".as_bytes(),
AttributeDefinition {
name: "id".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map.insert(
"defaultArrayLength".as_bytes(),
AttributeDefinition {
name: "defaultArrayLength".to_string(),
attribute_type: AttributeType::Integer,
required: true,
},
);
map.insert(
"index".as_bytes(),
AttributeDefinition {
name: "index".to_string(),
attribute_type: AttributeType::Integer,
required: true,
},
);
map.insert(
"dataProcessingRef".as_bytes(),
AttributeDefinition {
name: "dataProcessingRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"sourceFileRef".as_bytes(),
AttributeDefinition {
name: "sourceFileRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"spotID".as_bytes(),
AttributeDefinition {
name: "spotID".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map
};
pub(crate) static ref CHROMATOGRAM_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"id".as_bytes(),
AttributeDefinition {
name: "id".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map.insert(
"defaultArrayLength".as_bytes(),
AttributeDefinition {
name: "defaultArrayLength".to_string(),
attribute_type: AttributeType::Integer,
required: true,
},
);
map.insert(
"index".as_bytes(),
AttributeDefinition {
name: "index".to_string(),
attribute_type: AttributeType::Integer,
required: true,
},
);
map.insert(
"dataProcessingRef".as_bytes(),
AttributeDefinition {
name: "dataProcessingRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map
};
pub(crate) static ref SCAN_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"externalSpectrumID".as_bytes(),
AttributeDefinition {
name: "externalSpectrumID".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"instrumentConfigurationRef".as_bytes(),
AttributeDefinition {
name: "instrumentConfigurationRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"sourceFileRef".as_bytes(),
AttributeDefinition {
name: "sourceFileRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"spectrumRef".as_bytes(),
AttributeDefinition {
name: "spectrumRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map
};
pub(crate) static ref SAMPLE_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"id".as_bytes(),
AttributeDefinition {
name: "id".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map.insert(
"name".as_bytes(),
AttributeDefinition {
name: "name".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map
};
pub(crate) static ref SOFTWARE_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"id".as_bytes(),
AttributeDefinition {
name: "id".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map.insert(
"version".as_bytes(),
AttributeDefinition {
name: "version".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map
};
pub(crate) static ref INSTRUMENT_CONFIGURATION_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"id".as_bytes(),
AttributeDefinition {
name: "id".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map.insert(
"scanSettingsRef".as_bytes(),
AttributeDefinition {
name: "scanSettingsRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map
};
pub(crate) static ref COMPONENT_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"order".as_bytes(),
AttributeDefinition {
name: "order".to_string(),
attribute_type: AttributeType::Integer,
required: true,
},
);
map
};
pub(crate) static ref PROCESSING_METHOD_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"order".as_bytes(),
AttributeDefinition {
name: "order".to_string(),
attribute_type: AttributeType::Integer,
required: true,
},
);
map.insert(
"softwareRef".as_bytes(),
AttributeDefinition {
name: "softwareRef".to_string(),
attribute_type: AttributeType::String,
required: true,
},
);
map
};
pub(crate) static ref PRECURSOR_ATTRIBUTES: HashMap<&'static [u8], AttributeDefinition> = {
let mut map = HashMap::new();
map.insert(
"externalSpectrumID".as_bytes(),
AttributeDefinition {
name: "externalSpectrumID".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"sourceFileRef".as_bytes(),
AttributeDefinition {
name: "sourceFileRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map.insert(
"spectrumRef".as_bytes(),
AttributeDefinition {
name: "spectrumRef".to_string(),
attribute_type: AttributeType::String,
required: false,
},
);
map
};
}