Skip to content
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

Cleanup Rust API 1/5 #826

Merged
merged 13 commits into from
Sep 10, 2024
Merged
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ jobs:
- { name: pica-format, fuzz-dir: crates/pica-format/fuzz, target: fuzz-format, max-total-time: 300 }
- { name: pica-path, fuzz-dir: crates/pica-path/fuzz, target: fuzz-path, max-total-time: 300 }
- { name: pica-record-matcher, fuzz-dir: crates/pica-matcher/fuzz, target: fuzz-record-matcher, max-total-time: 300 }
- { name: pica-record-ref, fuzz-dir: pica-record/fuzz, target: fuzz-record-ref, max-total-time: 300 }
- { name: pica-record-ref-v1, fuzz-dir: crates/pica-record-v1/fuzz, target: fuzz-record-ref, max-total-time: 300 }
- { name: pica-select-query, fuzz-dir: crates/pica-select/fuzz, target: fuzz-query, max-total-time: 300 }
- { name: pica-record-ref, fuzz-dir: fuzz, target: fuzz-record-ref, max-total-time: 300 }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
Expand Down
34 changes: 31 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
[package]
name = "pica-record"
version = "0.1.0"
authors = ["Nico Wagner <[email protected]>"]
license = "EUPL-1.2"
keywords = ["PICA+", "code4lib"]
edition = "2021"
rust-version = "1.80"

[dependencies]
bstr = { version = "1.10" }
serde = { version = "1.0", optional = true, features = ["derive"] }
sha2 = { version = "0.10" }
thiserror = { version = "1" }
winnow = { version = "0.6.18" }

[features]
serde = ["dep:serde", "bstr/serde"]

[dev-dependencies]
pica-record = { path = "./", features = ["serde"] }
quickcheck = { version = "1.0" }
quickcheck_macros = { version = "1.0" }

[[test]]
path = "tests/lib.rs"
name = "integration"

[workspace]
resolver = "2"
default-members = ["crates/pica-toolkit"]
Expand All @@ -7,10 +35,10 @@ members = [
"crates/pica-lint",
"crates/pica-matcher",
"crates/pica-path",
"pica-record",
"crates/pica-record-v1",
"crates/pica-select",
"crates/pica-toolkit",
"crates/pica-utils"
"crates/pica-utils",
]

[workspace.package]
Expand All @@ -26,7 +54,7 @@ rust-version = "1.80"
pica-format = { version = "0.1", path = "./crates/pica-format" }
pica-matcher = { version = "0.25", path = "./crates/pica-matcher" }
pica-path = { version = "0.25", path = "./crates/pica-path" }
pica-record = { version = "0.25", path = "./pica-record" }
pica-record-v1 = { version = "0.25", path = "./crates/pica-record-v1" }
pica-select = { version = "0.25", path = "./crates/pica-select" }
pica-utils = { version = "0.25", path = "./crates/pica-utils" }

Expand Down
2 changes: 1 addition & 1 deletion crates/pica-format/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rust-version.workspace = true
[dependencies]
bstr = { workspace = true }
pica-matcher = { workspace = true }
pica-record = { workspace = true }
pica-record-v1 = { workspace = true }
thiserror = { workspace = true }
winnow = { workspace = true, features = ["simd"] }

Expand Down
2 changes: 1 addition & 1 deletion crates/pica-format/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::ops::RangeTo;
use std::str::FromStr;

use pica_matcher::{OccurrenceMatcher, SubfieldMatcher, TagMatcher};
use pica_record::{FieldRef, RecordRef, SubfieldCode, SubfieldRef};
use pica_record_v1::{FieldRef, RecordRef, SubfieldCode, SubfieldRef};
use thiserror::Error;
use winnow::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/pica-format/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bstr::ByteSlice;
use pica_matcher::parser::{
parse_occurrence_matcher, parse_subfield_matcher, parse_tag_matcher,
};
use pica_record::SubfieldCode;
use pica_record_v1::SubfieldCode;
use winnow::ascii::{digit1, multispace0, multispace1};
use winnow::combinator::{
alt, delimited, empty, opt, preceded, repeat, separated, terminated,
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-format/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;
use std::sync::OnceLock;

use pica_format::{Format, FormatExt, FormatOptions};
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;

type TestResult = anyhow::Result<()>;

Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ indicatif = { version = "0.17" }
once_cell = { version = "1.19" }
pica-matcher = { workspace = true, features = ["serde"] }
pica-path = { workspace = true, features = ["serde"] }
pica-record = { workspace = true }
pica-record-v1 = { workspace = true }
serde = { workspace = true, features = ["derive"] }
sophia = { version = "0.8" }
toml = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/checksum.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pica_path::{Path, PathExt};
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::{Lint, Status};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::Debug;

use chrono::NaiveDate;
use pica_path::{Path, PathExt};
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::{Lint, Status};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/filter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pica_matcher::{MatcherOptions, RecordMatcher};
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::{Lint, Status};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/iri.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::Debug;

use pica_path::{Path, PathExt};
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::{Lint, Status};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/iso639.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Mutex;

use once_cell::sync::Lazy;
use pica_path::{Path, PathExt};
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::{Lint, Status};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bstr::BString;
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use self::checksum::Checksum;
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/orcid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pica_path::{Path, PathExt};
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::{Lint, Status};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/refcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::{BTreeMap, BTreeSet};
use bstr::BString;
use pica_matcher::RecordMatcher;
use pica_path::{Path, PathExt};
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::{Lint, Status};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/lints/unicode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::{Lint, Status};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use pica_record::io::BufReadExt;
use pica_record_v1::io::BufReadExt;

use crate::cli::Args;
use crate::formatter::{CsvFormatter, Formatter};
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/rules/rule.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bstr::BString;
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::level::Level;
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-lint/src/rules/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::Path;
use bstr::ByteSlice;
use pica_matcher::RecordMatcher;
use pica_path::PathExt;
use pica_record::ByteRecord;
use pica_record_v1::ByteRecord;
use serde::Deserialize;

use super::rule::Rule;
Expand Down
2 changes: 1 addition & 1 deletion crates/pica-matcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ rust-version.workspace = true

[dependencies]
bstr = { workspace = true }
pica-record = { workspace = true }
pica-record-v1 = { workspace = true }
pica-utils = { workspace = true }
regex = { workspace = true }
serde = { workspace = true, optional = true }
Expand Down
14 changes: 7 additions & 7 deletions crates/pica-matcher/src/field_matcher.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Matcher that works on PICA+ [Fields](pica_record::Field).
//! Matcher that works on PICA+ [Fields](pica_record_v1::Field).

use std::cell::RefCell;
use std::ops::{BitAnd, BitOr, BitXor, Not};
use std::str::FromStr;

use bstr::ByteSlice;
use pica_record::FieldRef;
use pica_record_v1::FieldRef;
use winnow::ascii::digit1;
use winnow::combinator::{
alt, delimited, opt, preceded, repeat, terminated,
Expand Down Expand Up @@ -41,7 +41,7 @@ impl ExistsMatcher {
///
/// ```rust
/// use pica_matcher::field_matcher::ExistsMatcher;
/// use pica_record::FieldRef;
/// use pica_record_v1::FieldRef;
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
Expand Down Expand Up @@ -127,7 +127,7 @@ impl SubfieldsMatcher {
///
/// ```rust
/// use pica_matcher::field_matcher::SubfieldsMatcher;
/// use pica_record::FieldRef;
/// use pica_record_v1::FieldRef;
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
Expand Down Expand Up @@ -251,7 +251,7 @@ impl SingletonMatcher {
///
/// ```rust
/// use pica_matcher::field_matcher::SingletonMatcher;
/// use pica_record::FieldRef;
/// use pica_record_v1::FieldRef;
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
Expand Down Expand Up @@ -331,7 +331,7 @@ impl CardinalityMatcher {
///
/// ```rust
/// use pica_matcher::field_matcher::CardinalityMatcher;
/// use pica_record::FieldRef;
/// use pica_record_v1::FieldRef;
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
Expand Down Expand Up @@ -453,7 +453,7 @@ impl FieldMatcher {
///
/// ```rust
/// use pica_matcher::FieldMatcher;
/// use pica_record::FieldRef;
/// use pica_record_v1::FieldRef;
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
Expand Down
10 changes: 5 additions & 5 deletions crates/pica-matcher/src/occurrence_matcher.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use std::str::FromStr;

use bstr::{BStr, ByteSlice};
use pica_record::parser::parse_occurrence_digits;
use pica_record::{Occurrence, OccurrenceRef};
use pica_record_v1::parser::parse_occurrence_digits;
use pica_record_v1::{Occurrence, OccurrenceRef};
use winnow::combinator::{alt, empty, preceded, separated_pair};
use winnow::{PResult, Parser};

use crate::ParseMatcherError;

/// A matcher that matches against PICA+
/// [Occurrence](`pica_record::Occurrence`).
/// [Occurrence](`pica_record_v1::Occurrence`).
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum OccurrenceMatcher {
Any,
Expand All @@ -25,7 +25,7 @@ impl OccurrenceMatcher {
///
/// ```rust
/// use pica_matcher::OccurrenceMatcher;
/// use pica_record::Occurrence;
/// use pica_record_v1::Occurrence;
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
Expand All @@ -47,7 +47,7 @@ impl OccurrenceMatcher {
///
/// ```rust
/// use pica_matcher::OccurrenceMatcher;
/// use pica_record::OccurrenceRef;
/// use pica_record_v1::OccurrenceRef;
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
Expand Down
6 changes: 3 additions & 3 deletions crates/pica-matcher/src/record_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ops::{
use std::str::FromStr;

use bstr::ByteSlice;
use pica_record::RecordRef;
use pica_record_v1::RecordRef;
#[cfg(feature = "serde")]
use serde::Deserialize;
use winnow::Parser;
Expand All @@ -13,7 +13,7 @@ use crate::common::BooleanOp;
use crate::field_matcher::parse_field_matcher;
use crate::{FieldMatcher, MatcherOptions, ParseMatcherError};

/// A Matcher that works on PICA+ [Records](pica_record::Record).
/// A Matcher that works on PICA+ [Records](pica_record_v1::Record).
#[derive(Debug)]
pub struct RecordMatcher {
pub(crate) field_matcher: FieldMatcher,
Expand All @@ -26,7 +26,7 @@ impl RecordMatcher {
///
/// ```rust
/// use pica_matcher::RecordMatcher;
/// use pica_record::RecordRef;
/// use pica_record_v1::RecordRef;
///
/// # fn main() { example().unwrap(); }
/// fn example() -> anyhow::Result<()> {
Expand Down
Loading