#clash #file-server #different #tar #service

data-source

a simple crate that fetches data from different sources

2 releases

0.1.5 Mar 7, 2025
0.1.4 Mar 4, 2025
0.1.2 Feb 24, 2025

#511 in Data structures

Download history 343/week @ 2025-02-19 265/week @ 2025-02-26 561/week @ 2025-03-05 40/week @ 2025-03-12

1,209 downloads per month

MIT/Apache

32KB
734 lines

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),
);

Dependencies

~4–18MB
~255K SLoC