-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nonscalar parsing #26
base: trunk
Are you sure you want to change the base?
Conversation
@dkirkeby please provide an explanation of this PR. Also please rebase it, your branch is out of date and has conflicts. Conflicts should ideally be solved before code review. |
let station_id = parse_meta_field(parts.next().ok_or_else(next_err)?, "nationalnr")?; | ||
let type_id = parse_meta_field(parts.next().ok_or_else(next_err)?, "type")?; | ||
let message_id = parse_meta_field(parts.next().ok_or_else(next_err)?, "messageid")?; | ||
let mut header = ObsinnHeader::default(); | ||
for field in parts.by_ref() { | ||
if field.starts_with("nationalnr") { | ||
header.station_id = parse_meta_field(field)?; | ||
continue; | ||
} | ||
if field.starts_with("type") { | ||
header.type_id = parse_meta_field(field)?; | ||
continue; | ||
} | ||
if field.starts_with("messageid") { | ||
header.message_id = parse_meta_field(field)?; | ||
continue; | ||
} | ||
if field.starts_with("add") { | ||
// NOTE: this field has to do with data deletion/update in kvalobs, we do not use it | ||
header.add = true; | ||
continue; | ||
} | ||
if field.starts_with("received_time") { | ||
header.received_time = Some(parse_meta_field(field)?); | ||
continue; | ||
} | ||
return Err(Error::Parse(format!( | ||
"unexpected field in kldata header format: {field}", | ||
))); | ||
} | ||
|
||
if header.station_id == 0 { | ||
return Err(Error::Parse( | ||
"missing field `nationalnr` in kldata header".to_string(), | ||
)); | ||
} | ||
|
||
// TODO: type_id == 0 is present in stinfosys, so might be a bit dangerous to use here | ||
if header.type_id == 0 { | ||
return Err(Error::Parse( | ||
"missing field `type` in kldata header".to_string(), | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this part, but it shouldn't really be a thing. I need to speak with Søren again, there's no way the fields in the header can come in any order
No description provided.