#[repr(u8)]pub enum FormatKind {
Json = 0,
}Expand description
Data format kind for tape identification
Each tape carries a format marker indicating its source format, enabling format-specific parsing and transformation logic.
Variants§
Json = 0
JSON (JavaScript Object Notation) - base format
Implementations§
Source§impl FormatKind
impl FormatKind
Sourcepub const fn supports_comments(self) -> bool
pub const fn supports_comments(self) -> bool
Check if this format supports comments
Sourcepub const fn supports_references(self) -> bool
pub const fn supports_references(self) -> bool
Check if this format supports references/anchors
Source§impl FormatKind
impl FormatKind
Sourcepub fn detect_from_extension(ext: &str) -> Option<DetectionResult>
pub fn detect_from_extension(ext: &str) -> Option<DetectionResult>
Detect format from file extension
Returns Some(result) with Confidence::Exact for known extensions.
§Examples
use fionn_core::FormatKind;
let result = FormatKind::detect_from_extension("json").unwrap();
assert_eq!(result.format, FormatKind::Json);Sourcepub fn detect_from_mime_type(mime: &str) -> Option<DetectionResult>
pub fn detect_from_mime_type(mime: &str) -> Option<DetectionResult>
Detect format from MIME type
Returns Some(result) with Confidence::Exact for known MIME types.
§Examples
use fionn_core::FormatKind;
let result = FormatKind::detect_from_mime_type("application/json").unwrap();
assert_eq!(result.format, FormatKind::Json);Sourcepub fn detect_from_content(content: &[u8]) -> DetectionResult
pub fn detect_from_content(content: &[u8]) -> DetectionResult
Detect format from content by examining the first bytes
Uses heuristics to determine the most likely format. Returns the format with highest confidence, or JSON as fallback.
§Detection Heuristics
| Format | Detection Method |
|---|---|
| JSON | Starts with { or [ (after whitespace) |
| YAML | Contains --- document marker or : with indentation |
| TOML | Contains [section] or key = value patterns |
| CSV | Contains , with consistent structure per line |
| ISON | Contains :type: reference patterns |
| TOON | Contains indented tabular data with array headers |
§Examples
use fionn_core::FormatKind;
let json = r#"{"hello": "world"}"#;
let result = FormatKind::detect_from_content(json.as_bytes());
assert_eq!(result.format, FormatKind::Json);Sourcepub fn detect(
content: &[u8],
extension: Option<&str>,
mime_type: Option<&str>,
) -> DetectionResult
pub fn detect( content: &[u8], extension: Option<&str>, mime_type: Option<&str>, ) -> DetectionResult
Detect format using all available methods
Tries detection in order of reliability:
- File extension (if provided)
- MIME type (if provided)
- Content sniffing
Returns the result with highest confidence.
Trait Implementations§
Source§impl Clone for FormatKind
impl Clone for FormatKind
Source§fn clone(&self) -> FormatKind
fn clone(&self) -> FormatKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more