data-source

Crates.iodata-source
lib.rsdata-source
version0.1.5
created_at2025-02-19 12:56:59.551091+00
updated_at2025-03-07 13:33:12.854177+00
descriptiona simple crate that fetches data from different sources
homepagehttps://github.com/e1732a364fed/data-source
repositoryhttps://github.com/e1732a364fed/data-source
max_upload_size
id1561295
size31,032
e1732a364fed (e1732a364fed)

documentation

README

a simple crate that fetches data from different sources

supports tar, http, folders(as search paths), std::fs

Has a "file_server" feature, to serve files inside DataSource using axum:

use data_source::DataSource;
use data_source::file_server::*;
let mut data_source = DataSource::FileMap(Default::default());
let app = axum::Router::new();
let app = register_data_source_route(app,  "/files/*path", data_source);

Or

use data_source::DataSource;
use data_source::file_server::*;
let mut data_source = DataSource::FileMap(Default::default());
let app = axum::Router::new();
let service = DataSourceService::new(data_source);
 use axum::extract::Path as AxumPath;


async fn handle_file_request_wrapper(
    path: AxumPath<String>,
    State(mut service): State<DataSourceService>,
) -> impl IntoResponse {
    handle_file_request(path, &mut service).await
}

app = app.route(
    "/files/*path",
    get(handle_file_request_wrapper).with_state(service),
);
Commit count: 22

cargo fmt