Skip to content

Release v1.2.0

Choose a tag to compare

@m62624 m62624 released this 04 Jan 07:17
· 10 commits to main since this release

[1.2.0] - 2024.01.04

Fixed

  • Resolved issue with byte mode in FileIter. It now correctly handles chunk sizes.

Added

  • Implemented TryFrom for FileIter with support for various input types:
    • File --> FileIter
    • BufReader<File> --> FileIter
    • Vec<u8> --> FileIter
    • &Vec<u8> --> FileIter
    • io::Cursor<Vec<u8>> --> FileIter
    • BufReader<io::Cursor<Vec<u8>>> --> FileIter
    • &[u8] --> FileIter
    • &str --> FileIter (equivalent to the new method)
    • String --> FileIter (equivalent to the new method)
    • Cow<'_, str> --> FileIter (equivalent to the new method)

Example

use get_chunk::iterator::FileIter;
use std::{fs::File, io};

fn main() -> io::Result<()> {
    let file = FileIter::try_from(File::open("src/main.rs")?)?;
    for chunk in file {
        // ...
    }
    Ok(())
}

  • Implemented TryFrom for FileStream with custom trait to support async operations (use the try_from_data method instead of try_from):
    • File --> FileIter
    • BufReader<File> --> FileIter
    • Vec<u8> --> FileIter
    • io::Cursor<Vec<u8>> --> FileIter
    • BufReader<io::Cursor<Vec<u8>>> --> FileIter
    • String --> FileIter (equivalent to the new method)

Example

use get_chunk::stream::{FileStream, StreamExt, TryFrom};
use tokio::{fs::File, io};

#[tokio::main]
async fn main() -> io::Result<()> {
    let mut file = FileStream::try_from_data(File::open("src/main.rs").await?).await?;
    while let Some(chunk) = file.next().await {
        // ...
    }
    Ok(())
}