#![allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum TypePhaseId {
HighPriorityPredicate,
MagicAndBrand,
Extension,
TruncatedMagic,
StructuredAndTextPattern,
StandardPredicateAndFallback,
}
#[derive(Debug, Clone, Copy)]
pub struct StructuredProbeSpec {
pub id: &'static str,
pub family: &'static str,
pub marker: &'static str,
pub markers: &'static [&'static str],
pub mime: &'static str,
pub matched_rule: &'static str,
pub confidence: f32,
}
pub const TYPE_DEFAULT_UNIVERSE: &str = "U0";
pub const TYPE_BINARY_SAMPLE_BYTES: usize = 4096;
pub const TYPE_BINARY_NON_TEXT_RATIO: f32 = 0.3_f32;
pub const TYPE_XML_SVG_SAMPLE_CHARS: usize = 512;
pub const TYPE_MIN_HIGH_PRIORITY_EXCLUSIVE: i32 = 0;
pub const TYPE_CONF_HIGH_PRIORITY: f32 = 1.0_f32;
pub const TYPE_CONF_MAGIC_SIGNATURE: f32 = 0.99_f32;
pub const TYPE_CONF_MAGIC_BRAND: f32 = 0.99_f32;
pub const TYPE_CONF_EXTENSION_HINT: f32 = 0.95_f32;
pub const TYPE_CONF_TRUNCATED_MAGIC: f32 = 0.5_f32;
pub const TYPE_CONF_TEXT_PATTERN: f32 = 0.95_f32;
pub const TYPE_CONF_STANDARD_PREDICATE: f32 = 0.92_f32;
pub const TYPE_CONF_FALLBACK: f32 = 0.5_f32;
pub const TYPE_RULE_HIGH_PRIORITY: &str = "programmatic_predicate_high_priority";
pub const TYPE_RULE_MAGIC_BYTES: &str = "magic_bytes";
pub const TYPE_RULE_EXTENSION_HINT: &str = "extension_hint";
pub const TYPE_RULE_TRUNCATED_MAGIC: &str = "binary_fallback";
pub const TYPE_RULE_TEXT_PATTERN: &str = "text_pattern";
pub const TYPE_RULE_STANDARD_PREDICATE: &str = "programmatic_predicate";
pub const TYPE_RULE_BINARY_FALLBACK: &str = "binary_fallback";
pub const TYPE_RULE_TEXT_FALLBACK: &str = "text_fallback";
pub const TYPE_FALLBACK_BINARY_EXT: &str = ".bin";
pub const TYPE_FALLBACK_BINARY_CATEGORY: &str = "binary";
pub const TYPE_FALLBACK_TEXT_EXT: &str = ".txt";
pub const TYPE_FALLBACK_TEXT_CATEGORY: &str = "text";
pub const TYPE_BRAND_DEFAULT_CATEGORY: &str = "media";
pub const TYPE_UNKNOWN_CATEGORY: &str = "unknown";
pub const TYPE_PHASE_ORDER: &[TypePhaseId] = &[
TypePhaseId::HighPriorityPredicate,
TypePhaseId::MagicAndBrand,
TypePhaseId::Extension,
TypePhaseId::TruncatedMagic,
TypePhaseId::StructuredAndTextPattern,
TypePhaseId::StandardPredicateAndFallback,
];
pub const STRUCTURED_PROBE_TABLE: &[StructuredProbeSpec] = &[
StructuredProbeSpec { id: "json_mcard", family: "json", marker: "\"mcard_version\"", markers: &["\"mcard_version\""], mime: "application/vnd.mcard+json", matched_rule: "structured_mcard_probe", confidence: 0.99_f32 },
StructuredProbeSpec { id: "json_pcard", family: "json", marker: "\"pcard_version\"", markers: &["\"pcard_version\""], mime: "application/vnd.pcard+json", matched_rule: "structured_pcard_probe", confidence: 0.99_f32 },
StructuredProbeSpec { id: "json_vcard", family: "json", marker: "\"vcard_version\"", markers: &["\"vcard_version\""], mime: "application/vnd.vcard+json", matched_rule: "structured_vcard_probe", confidence: 0.99_f32 },
StructuredProbeSpec { id: "json_generic", family: "json", marker: "", markers: &[], mime: "application/json", matched_rule: "structured_json_probe", confidence: 0.98_f32 },
StructuredProbeSpec { id: "xml_svg", family: "xml_or_svg", marker: "<svg", markers: &["<svg"], mime: "image/svg+xml", matched_rule: "structured_svg_probe", confidence: 0.96_f32 },
StructuredProbeSpec { id: "xml_generic", family: "xml_or_svg", marker: "<?xml", markers: &["<?xml"], mime: "application/xml", matched_rule: "structured_xml_probe", confidence: 0.92_f32 },
StructuredProbeSpec { id: "html", family: "html", marker: "<!doctype html|<html", markers: &["<!doctype html", "<html"], mime: "text/html", matched_rule: "structured_html_probe", confidence: 0.95_f32 },
StructuredProbeSpec { id: "markdown_frontmatter", family: "frontmatter", marker: "---\n---", markers: &["---", "\n---"], mime: "text/markdown", matched_rule: "markdown_frontmatter_probe", confidence: 0.9_f32 },
StructuredProbeSpec { id: "latex_tikz", family: "tex", marker: "\\begin{tikzpicture}", markers: &["\\begin{tikzpicture}"], mime: "text/x-tikz", matched_rule: "structured_tikz_probe", confidence: 0.95_f32 },
StructuredProbeSpec { id: "latex_generic", family: "tex", marker: "\\documentclass|\\begin{document}", markers: &["\\documentclass", "\\begin{document}"], mime: "text/x-tex", matched_rule: "structured_latex_probe", confidence: 0.92_f32 },
];
pub fn build_type_phase_pipeline<I, O>(
high_priority_predicate: fn(&I) -> Option<O>,
magic_and_brand: fn(&I) -> Option<O>,
extension: fn(&I) -> Option<O>,
truncated_magic: fn(&I) -> Option<O>,
structured_and_text_pattern: fn(&I) -> Option<O>,
standard_predicate_and_fallback: fn(&I) -> Option<O>,
) -> [fn(&I) -> Option<O>; 6] {
[
high_priority_predicate,
magic_and_brand,
extension,
truncated_magic,
structured_and_text_pattern,
standard_predicate_and_fallback,
]
}