Crates.io | cloud-file |
lib.rs | cloud-file |
version | 0.2.0 |
source | src |
created_at | 2024-01-29 03:05:48.819357 |
updated_at | 2024-10-17 15:17:37.365302 |
description | Simple reading of cloud files in Rust |
homepage | https://github.com/CarlKCarlK/cloud-file |
repository | https://github.com/CarlKCarlK/cloud-file |
max_upload_size | |
id | 1118283 |
size | 114,203 |
Simple reading of cloud files in Rust
object_store
crate, focusing on a useful subset of its featurescargo add cloud-file
Find the size of a cloud file.
use cloud_file::CloudFile;
# Runtime::new().unwrap().block_on(async { // '#' needed for doctest
let url = "https://raw.githubusercontent.com/fastlmm/bed-sample-files/main/toydata.5chrom.fam";
let cloud_file = CloudFile::new(url)?;
let file_size = cloud_file.read_file_size().await?;
assert_eq!(file_size, 14_361);
# Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
# use {cloud_file::CloudFileError, tokio::runtime::Runtime};
Find the number of lines in a cloud file.
use cloud_file::CloudFile;
use futures::StreamExt; // Enables `.next()` on streams.
# Runtime::new().unwrap().block_on(async { // '#' needed for doctest
let url = "https://raw.githubusercontent.com/fastlmm/bed-sample-files/main/toydata.5chrom.fam";
let cloud_file = CloudFile::new_with_options(url, [("timeout", "30s")])?;
let mut chunks = cloud_file.stream_chunks().await?;
let mut newline_count: usize = 0;
while let Some(chunk) = chunks.next().await {
let chunk = chunk?;
newline_count += bytecount::count(&chunk, b'\n');
}
assert_eq!(newline_count, 500);
# Ok::<(), Box<dyn std::error::Error>>(()) }).unwrap();
# use {cloud_file::CloudFileError, tokio::runtime::Runtime};
Example | Demonstrates |
---|---|
line_count |
Read a file as binary chunks. |
nth_line |
Read a file as text lines. |
bigram_counts |
Read random regions of a file, without regard to order. |
aws_file_size |
Find the size of a file on AWS. |