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

API using Read trait #76

Closed
wants to merge 21 commits into from
Closed

API using Read trait #76

wants to merge 21 commits into from

Conversation

bojand
Copy link
Owner

@bojand bojand commented Sep 19, 2022

Initial work and idea to support Read trait.

Addresses #51.

Example usage:

use std::fs;
use std::io::prelude::*;
use std::fs::File;

fn main() -> std::io::Result<()> {
    let info = infer::Infer::new();
    let mut f = File::open("testdata/sample.jpg")?;
    let kind = info.get_read(&mut f).unwrap().expect("file type is known");
    assert_eq!(kind.mime_type(), "image/jpeg");
    assert_eq!(kind.extension(), "jpg");
    Ok(())
}

Complementary *_read functions are provided to match existing ones that take a buffer.

@bojand bojand closed this Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant