• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / bibdata / 880759a6-1cd8-4c26-ac18-7fa2f37cee33

14 Aug 2025 04:24PM UTC coverage: 92.642% (+0.02%) from 92.625%
880759a6-1cd8-4c26-ac18-7fa2f37cee33

Pull #2849

circleci

sandbergja
Rename module for clarity

Co-authored-by: Christina Chortaria <christinach@users.noreply.github.com>
Pull Request #2849: Refactor format facet code to Rust

325 of 361 new or added lines in 8 files covered. (90.03%)

5 existing lines in 1 file now uncovered.

6988 of 7543 relevant lines covered (92.64%)

429.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.31
/lib/bibdata_rs/src/marc/fixed_field/physical_description.rs
1
// This module concerns field 007: Physical Description
2

3
use std::str::FromStr;
4

5
use marctk::Record;
6

7
pub enum CategoryOfMaterial {
8
    Map,
9
    ElectronicResource,
10
    Globe,
11
    TactileMaterial,
12
    ProjectedGraphic,
13
    Microform,
14
    NonProjectedGraphic,
15
    MotionPicture,
16
    Kit,
17
    NotatedMusic,
18
    RemoteSensingImage,
19
    SoundRecording,
20
    Text,
21
    VideoRecording,
22
    Unspecified,
23
}
24

25
#[derive(Debug)]
26
pub struct NoSuchCategoryOfMaterial;
27

28
impl FromStr for CategoryOfMaterial {
29
    type Err = NoSuchCategoryOfMaterial;
30

31
    fn from_str(s: &str) -> Result<Self, Self::Err> {
3✔
32
        match s.chars().next() {
3✔
NEW
33
            Some('a') => Ok(CategoryOfMaterial::Map),
×
NEW
34
            Some('c') => Ok(CategoryOfMaterial::ElectronicResource),
×
NEW
35
            Some('d') => Ok(CategoryOfMaterial::Globe),
×
NEW
36
            Some('f') => Ok(CategoryOfMaterial::TactileMaterial),
×
NEW
37
            Some('g') => Ok(CategoryOfMaterial::ProjectedGraphic),
×
38
            Some('h') => Ok(CategoryOfMaterial::Microform),
3✔
NEW
39
            Some('k') => Ok(CategoryOfMaterial::NonProjectedGraphic),
×
NEW
40
            Some('m') => Ok(CategoryOfMaterial::MotionPicture),
×
NEW
41
            Some('o') => Ok(CategoryOfMaterial::Kit),
×
NEW
42
            Some('q') => Ok(CategoryOfMaterial::NotatedMusic),
×
NEW
43
            Some('r') => Ok(CategoryOfMaterial::RemoteSensingImage),
×
NEW
44
            Some('s') => Ok(CategoryOfMaterial::SoundRecording),
×
NEW
45
            Some('t') => Ok(CategoryOfMaterial::Text),
×
NEW
46
            Some('v') => Ok(CategoryOfMaterial::VideoRecording),
×
NEW
47
            Some('z') => Ok(CategoryOfMaterial::Unspecified),
×
NEW
48
            _ => Err(NoSuchCategoryOfMaterial),
×
49
        }
50
    }
3✔
51
}
52

53
pub fn categories_of_material(record: &Record) -> Vec<CategoryOfMaterial> {
30✔
54
    record
30✔
55
        .get_control_fields("007")
30✔
56
        .iter()
30✔
57
        .filter_map(|field| CategoryOfMaterial::from_str(field.content()).ok())
30✔
58
        .collect()
30✔
59
}
30✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc