File tree Expand file tree Collapse file tree 2 files changed +34
-6
lines changed
Expand file tree Collapse file tree 2 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " sqlite-vfs-http"
3- version = " 0.1.0 "
3+ version = " 0.1.1 "
44edition = " 2021"
55authors = [" DarkSky <darksky2048@gmail.com>" ]
66license = " AGPL-3.0-only"
Original file line number Diff line number Diff line change @@ -12,10 +12,38 @@ use vfs::HttpVfs;
1212
1313pub use vfs:: HTTP_VFS ;
1414
15- pub fn register_http_vfs ( ) {
16- const ONCE : Once = Once :: new ( ) ;
15+ pub struct HttpVfsRegister {
16+ block_size : usize ,
17+ download_threshold : usize ,
18+ }
19+
20+ impl HttpVfsRegister {
21+ pub fn new ( ) -> Self {
22+ Self {
23+ block_size : 1024 * 1024 * 4 ,
24+ download_threshold : 1024 ,
25+ }
26+ }
27+
28+ pub fn with_block_size ( self , block_size : usize ) -> Self {
29+ Self { block_size, ..self }
30+ }
31+
32+ pub fn register ( self ) {
33+ const ONCE : Once = Once :: new ( ) ;
1734
18- ONCE . call_once ( || {
19- let _ = register ( HTTP_VFS , HttpVfs :: default ( ) , true ) ;
20- } )
35+ let vfs_instance = HttpVfs {
36+ block_size : self . block_size ,
37+ download_threshold : self . download_threshold ,
38+ } ;
39+
40+ ONCE . call_once ( || {
41+ let _ = register ( HTTP_VFS , vfs_instance, true ) ;
42+ } )
43+ }
44+ }
45+
46+ #[ inline( always) ]
47+ pub fn register_http_vfs ( ) {
48+ HttpVfsRegister :: new ( ) . register ( ) ;
2149}
You can’t perform that action at this time.
0 commit comments