grippo 0.1.3

Parse, match and scrub data at scale.
Documentation
// Project:   grippo
// File:      src/shared_tests.rs
// Purpose:   Every public type is Send and Sync, checked at compile time
// Language:  Rust
//
// License:   Apache-2.0
// Copyright: (c) 2026 HYPERI PTY LIMITED

//! A type that stops being `Send` or `Sync` stops this file compiling, so an
//! async caller never finds out from a future that won't spawn.

const fn shared<T: Send + Sync>() {}

#[test]
fn the_core_types_are_shared() {
    shared::<crate::MatcherTier>();
    shared::<crate::cost::Cost>();
    shared::<crate::cost::Line>();
}

#[cfg(feature = "strmatch")]
#[test]
fn the_matchers_are_shared() {
    use crate::strmatch::{
        BuildError, Captures, Match, OnBelowMin, ReplaceSyntax, Replacement, SetMatch, Signature,
        SignatureBuilder, SignatureError, SignatureMatch, SignatureScratch, SignatureSet,
        Specificity, StrMatcher, StrMatcherBuilder, StrMatcherSet, Verify,
    };
    #[cfg(feature = "glob")]
    {
        shared::<crate::strmatch::GlobBuilder>();
        shared::<crate::strmatch::GlobMatcher>();
    }
    shared::<BuildError>();
    shared::<Captures>();
    shared::<Match>();
    shared::<ReplaceSyntax>();
    shared::<Replacement>();
    shared::<OnBelowMin>();
    shared::<SetMatch>();
    shared::<Signature>();
    shared::<SignatureBuilder>();
    shared::<SignatureError>();
    shared::<SignatureMatch>();
    shared::<SignatureScratch>();
    shared::<SignatureSet>();
    shared::<Specificity>();
    shared::<StrMatcher>();
    shared::<StrMatcherBuilder>();
    shared::<StrMatcherSet>();
    shared::<Verify>();
}

#[cfg(feature = "parse")]
#[test]
fn the_parse_types_are_shared() {
    use crate::field::{Field, Scan};
    use crate::parse::{
        Batch, Chain, ChainError, CompileError, Event, Failure, FallbackConfig, FieldValue, Fields,
        FormatChoice, Frame, FrameState, FramingConfig, Hint, HopConfig, Input, MultiLineConfig,
        Number, Outcome, ParseConfig, ParseError, ParsePlan, Parsed, Parsers, PrefixStack,
        ResolveError, Settings, SinkMark, SourceState, Status, Step, Trace,
    };
    shared::<Batch<'static>>();
    shared::<Chain>();
    shared::<ChainError>();
    shared::<CompileError>();
    shared::<Event>();
    shared::<Failure>();
    shared::<FallbackConfig>();
    shared::<Field>();
    shared::<FieldValue<'static>>();
    shared::<Fields<'static>>();
    shared::<FormatChoice>();
    shared::<Frame<'static>>();
    shared::<FrameState>();
    shared::<FramingConfig>();
    shared::<Hint>();
    shared::<HopConfig>();
    shared::<Input>();
    shared::<MultiLineConfig>();
    shared::<Number>();
    shared::<Outcome>();
    shared::<ParseConfig>();
    shared::<ParseError>();
    shared::<ParsePlan>();
    shared::<Parsed>();
    shared::<Parsers>();
    shared::<PrefixStack>();
    shared::<ResolveError>();
    shared::<Scan>();
    shared::<Settings>();
    shared::<SinkMark>();
    shared::<SourceState>();
    shared::<Status>();
    shared::<Step>();
    shared::<Trace>();
    #[cfg(feature = "both-paths")]
    {
        use crate::parse::both_paths::{CheckError, Disagreement, Written};
        shared::<CheckError>();
        shared::<Disagreement>();
        shared::<Written>();
    }
}

#[cfg(feature = "time")]
#[test]
fn the_time_types_are_shared() {
    use crate::time::{
        EpochUnit, FormatCache, Fraction, JavaPattern, RenderFormat, Stamp, StrptimeDialect,
        TimeDefaults, TimeError, TimeFormat, YearRule,
    };
    shared::<EpochUnit>();
    shared::<JavaPattern>();
    shared::<FormatCache>();
    shared::<Fraction>();
    shared::<RenderFormat>();
    shared::<Stamp>();
    shared::<YearRule>();
    shared::<StrptimeDialect>();
    shared::<TimeDefaults>();
    shared::<TimeError>();
    shared::<TimeFormat>();
}

#[cfg(feature = "parse-grok")]
#[test]
fn the_grok_types_are_shared() {
    use crate::grok::spec::{Class, Compiled, Op, Steps};
    use crate::grok::{
        Capture, Dialect, Expanded, Filter, Grok, GrokBuildError, GrokBuilder, GrokError, Library,
    };
    shared::<Capture>();
    shared::<Class>();
    shared::<Compiled>();
    shared::<Dialect>();
    shared::<Expanded>();
    shared::<Filter>();
    shared::<Grok>();
    shared::<GrokBuildError>();
    shared::<GrokBuilder>();
    shared::<GrokError>();
    shared::<Library>();
    shared::<Op>();
    shared::<Steps>();
}

#[test]
fn the_stock_parsers_are_shared() {
    #[cfg(feature = "parse-cef")]
    shared::<crate::format::cef::Cef>();
    #[cfg(feature = "parse-cri")]
    shared::<crate::format::cri::Cri>();
    #[cfg(feature = "parse-csv")]
    {
        shared::<crate::format::csv::Csv>();
        shared::<crate::format::csv::CsvConfig>();
        shared::<crate::format::csv::CsvConfigError>();
        shared::<crate::format::csv::CsvReader>();
        shared::<crate::format::csv::ColumnNames>();
        shared::<crate::format::csv::CsvError>();
        shared::<crate::format::csv::Quoting>();
        shared::<crate::format::csv::Ragged>();
    }
    #[cfg(feature = "parse-dissect")]
    {
        shared::<crate::format::dissect::Dissect>();
        shared::<crate::format::dissect::DissectConfig>();
        shared::<crate::format::dissect::DissectError>();
    }
    #[cfg(feature = "parse-gelf")]
    shared::<crate::format::gelf::Gelf>();
    #[cfg(feature = "parse-kv")]
    {
        shared::<crate::format::kv::Kv>();
        shared::<crate::format::kv::KvConfig>();
        shared::<crate::format::kv::KvConfigError>();
    }
    #[cfg(feature = "parse-leef")]
    shared::<crate::format::leef::Leef>();
    #[cfg(feature = "parse-ndjson")]
    shared::<crate::format::ndjson::Ndjson>();
    #[cfg(feature = "parse-syslog")]
    shared::<crate::format::syslog::Syslog>();
    #[cfg(feature = "parse-xml")]
    {
        shared::<crate::format::xml::Keyed>();
        shared::<crate::format::xml::Xml>();
        shared::<crate::format::xml::XmlConfigError>();
        shared::<crate::format::xml::XmlParserConfig>();
    }
}

#[cfg(feature = "scrub")]
#[test]
fn the_scrub_types_are_shared() {
    use crate::scrub::field::{CredentialMatcher, Spellings};
    use crate::scrub::{
        AllowMarker, AllowlistConfig, Entry, Finding, HashKey, Kind, Layer, Layers, Redaction,
        Report, RuleConfig, RuleSpec, ScrubError, ScrubScratch, Scrubber, ScrubberBuilder,
        SkipReason, Skipped, Strictness,
    };
    shared::<AllowMarker>();
    shared::<AllowlistConfig>();
    shared::<CredentialMatcher>();
    shared::<Entry<'static>>();
    shared::<Finding<'static>>();
    shared::<HashKey>();
    shared::<Kind>();
    shared::<Layer>();
    shared::<Layers>();
    shared::<Redaction>();
    shared::<Report>();
    shared::<RuleConfig>();
    shared::<RuleSpec>();
    shared::<ScrubError>();
    shared::<ScrubScratch>();
    shared::<Scrubber>();
    shared::<ScrubberBuilder>();
    shared::<SkipReason>();
    shared::<Skipped>();
    shared::<Spellings>();
    shared::<Strictness>();
}

#[cfg(feature = "xml")]
#[test]
fn the_xml_types_are_shared() {
    use crate::xml::{
        Arrays, DialectMode, DialectSpec, FaultPaths, Namespaces, RecordSpec, RegistryError,
        SoapFault, XmlConfig, XmlError, XmlLimits, XmlRecords,
    };
    shared::<Arrays>();
    shared::<DialectMode>();
    shared::<DialectSpec>();
    shared::<FaultPaths>();
    shared::<Namespaces>();
    shared::<RecordSpec>();
    shared::<RegistryError>();
    shared::<SoapFault>();
    shared::<XmlConfig>();
    shared::<XmlError>();
    shared::<XmlLimits>();
    shared::<XmlRecords>();
}

#[cfg(feature = "convert")]
#[test]
fn the_convert_types_are_shared() {
    use crate::convert::{ConvertError, IpText, Width};
    shared::<ConvertError>();
    shared::<IpText<'static>>();
    shared::<Width>();
}

#[cfg(feature = "domain")]
#[test]
fn the_domain_types_are_shared() {
    use crate::domain::{Case, DomainSplit, Kind};
    shared::<Case>();
    shared::<DomainSplit<'static>>();
    shared::<Kind>();
}

#[cfg(feature = "ua")]
#[test]
fn the_ua_types_are_shared() {
    use crate::ua::{
        Client, Device, DeviceRule, Domain, Os, OsRule, RegexFlag, Rules, UaError, UaParser,
        UaScratch, UserAgent, UserAgentRule,
    };
    shared::<Client<'static>>();
    shared::<Device<'static>>();
    shared::<DeviceRule>();
    shared::<Domain>();
    shared::<Os<'static>>();
    shared::<OsRule>();
    shared::<RegexFlag>();
    shared::<Rules>();
    shared::<UaError>();
    shared::<UaParser>();
    shared::<UaScratch>();
    shared::<UserAgent<'static>>();
    shared::<UserAgentRule>();
}

#[cfg(feature = "uri")]
#[test]
fn the_uri_types_are_shared() {
    use crate::uri::UriRef;
    use crate::uri::java::{JavaParts, Reading};
    use crate::uri::percent::{BadEscape, Mode, PercentError, Plus, Utf8};
    shared::<BadEscape>();
    shared::<JavaParts<'static>>();
    shared::<Mode>();
    shared::<PercentError>();
    shared::<Plus>();
    shared::<Reading>();
    shared::<UriRef<'static>>();
    shared::<Utf8>();
}

#[cfg(feature = "record")]
#[test]
fn the_record_types_are_shared() {
    use crate::record::{Json, Line, Miss, Typed};
    shared::<Json<'static>>();
    shared::<Line<'static>>();
    shared::<Miss>();
    shared::<Typed<'static>>();
    #[cfg(feature = "parse")]
    {
        use crate::record::{FieldsAt, LayerCache, LayerError, LayerPlan, Layered, LayeredAt};
        use crate::record::{Source, SourceAt};
        shared::<FieldsAt<'static>>();
        shared::<LayerCache<'static>>();
        shared::<LayerError>();
        shared::<LayerPlan>();
        shared::<Layered<'static, Json<'static>>>();
        shared::<LayeredAt<'static, &'static str>>();
        shared::<Source<'static>>();
        shared::<SourceAt<'static>>();
    }
}