Expand description
Determines file content types using AI.
This library indirectly depends on the ONNX Runtime through the ort crate. The
final user is responsible to make sure the ONNX Runtime is available. The ort crate provides
many options in this regard. The simplest option is to enable the default cargo
features of the ort crate by adding the following dependency to the
Cargo.toml file of the final binary:
[dependencies]
ort = "=2.0.0-rc.12"§Examples
// A Magika session can be used multiple times across multiple threads.
let mut magika = magika::Session::new()?;
// Files can be identified from their path.
assert_eq!(magika.identify_file_sync("src/lib.rs")?.info().label, "rust");
// Contents can also be identified directly from memory.
let result = magika.identify_content_sync(&b"#!/bin/sh\necho hello"[..])?;
assert_eq!(result.info().label, "shell");Structs§
- Builder
- Configures and creates a Magika session.
- Features
- Features to identify a file using AI.
- Inferred
Type - Content type identified using AI.
- Session
- A Magika session to identify files.
- Type
Info - File type information.
Enums§
- Content
Type - Content types for regular files.
- Error
- Errors returned by Magika functions.
- Features
OrRuled - Result of features extraction.
- File
Type - File types.
- Overwrite
Reason - Reason to overwrite an inferred content type.
Constants§
- MODEL_
MAJOR_ VERSION - Model major version.
- MODEL_
NAME - Model name (only comparable with equality).
Traits§
- Async
Input - Asynchronous abstraction over file content.
- Sync
Input - Synchronous abstraction over file content.
Type Aliases§
- Result
- Result type of Magika functions.