Skip to content

Commit

Permalink
Wrap subfield value in SubfieldValue type (#818)
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Wagner <[email protected]>
  • Loading branch information
nwagner84 authored Sep 2, 2024
1 parent 344d126 commit c80f3bd
Show file tree
Hide file tree
Showing 4 changed files with 305 additions and 58 deletions.
2 changes: 1 addition & 1 deletion crates/pica-path/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl<'a> PathExt for RecordRef<'a> {
.flat_map(FieldRef::subfields)
.filter_map(|subfield| {
if path.codes_flat().contains(subfield.code()) {
Some(subfield.value())
Some(subfield.value().as_bstr())
} else {
None
}
Expand Down
3 changes: 3 additions & 0 deletions pica-record/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use thiserror::Error;
pub enum PicaError {
#[error("'{0}' is not a valid subfield code.")]
InvalidSubfieldCode(char),

#[error("'{0}' is not a valid subfield value.")]
InvalidSubfieldValue(String),
}

/// -----{ TODO }-----------------------------------------
Expand Down
12 changes: 10 additions & 2 deletions pica-record/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@
//! select).

pub use error::PicaError;
pub use subfield::SubfieldCode;
pub use subfield::{SubfieldCode, SubfieldValue, SubfieldValueRef};

/// Parsers recognizing low-level primitives (e.g. subfield codes).
#[rustfmt::skip]
pub mod parser_v2 {
pub use super::subfield::parse_subfield_code;
pub use super::subfield::parse_subfield_value_ref;
}

// -----{ TODO }-----------------------------------------

/// -----{ TODO }-----------------------------------------
mod error;
mod field;
pub mod io;
Expand Down
Loading

0 comments on commit c80f3bd

Please sign in to comment.