#file #desktop #web #async #load-file #serve #request

platter2

Load files on web and desktop asynchronously

2 releases

0.1.6 Aug 5, 2022
0.1.5 Aug 5, 2022

#1305 in Filesystem

Download history 187/week @ 2024-07-20 239/week @ 2024-07-27 163/week @ 2024-08-03 223/week @ 2024-08-10 201/week @ 2024-08-17 225/week @ 2024-08-24 237/week @ 2024-08-31 245/week @ 2024-09-07 274/week @ 2024-09-14 439/week @ 2024-09-21 313/week @ 2024-09-28 166/week @ 2024-10-05 168/week @ 2024-10-12 242/week @ 2024-10-19 257/week @ 2024-10-26 215/week @ 2024-11-02

894 downloads per month
Used in 16 crates (via notan_app)

MIT OR Apache-2.0 OR Zlib

11KB
173 lines

platter2

This is a fork of platter with some upgrades and fixes.

Thanks, @ryanisaacg, for your hard work.

--

A simple utility to serve you files on a platter

platter2 works on both desktop and web, and returns a byte buffer of the file's contents. On desktop, load_file is backed by native file system APIs. On web, it is backed by an HTTP 'GET' request.

let file_contents = load_file("path_to_my_file").await?;

Web Support

To use platter2 on the web, enable either the web-sys feature (for wasm-pack and wasm-bindgen workflows) or the stdweb feature (for stdweb and cargo-web workflows).


lib.rs:

A simple utility to serve you files on a platter

platter works on both desktop and web, and returns a byte buffer of the file's contents. On desktop, load_file is backed by native file system APIs. On web, it is backed by an HTTP 'GET' request.

To use platter on the web, you'll need to choose either the stdweb or web-sys feature and enable it. This determines which method of binding to browser APIs platter will use.

Dependencies

~0.5–3.5MB
~63K SLoC