remi-dupre / aoc

A macro which defines a handful main for the Advent of Code
Apache License 2.0
35 stars 7 forks source link

Add a `standalone` feature #10

Open remi-dupre opened 3 years ago

remi-dupre commented 3 years ago

For linux dirs could be replaced by just reading the $HOME env var and we could use curl instead of compiling a whole http client for just a daily download.

swlody commented 3 years ago

With regards to the http client, I tried using minreq after reading this article and it seems to have pretty similar dependencies to curl (26 vs 22) and substantially less than attohttpc (41) while also compiling a bit faster than curl.

// Using curl
PS C:\Users\Sam\Code\curltest> cargo build
   Compiling pkg-config v0.3.19
   Compiling cc v1.0.66
   Compiling vcpkg v0.2.11
   Compiling winapi v0.3.9
   Compiling libc v0.2.81
   Compiling curl v0.4.34
   Compiling lazy_static v1.4.0
   Compiling libz-sys v1.1.2
   Compiling curl-sys v0.4.39+curl-7.74.0
   Compiling socket2 v0.3.17
   Compiling schannel v0.1.19
   Compiling curltest v0.1.0 (C:\Users\Sam\Code\curltest)
    Finished dev [unoptimized + debuginfo] target(s) in 15.69s

// Using minreq
PS C:\Users\Sam\Code\curltest> cargo build
   Compiling winapi v0.3.9
   Compiling cc v1.0.66
   Compiling spin v0.5.2
   Compiling untrusted v0.7.1
   Compiling byteorder v1.3.4
   Compiling log v0.4.11
   Compiling cfg-if v0.1.10
   Compiling minreq v2.2.1
   Compiling lazy_static v1.4.0
   Compiling base64 v0.10.1
   Compiling ring v0.16.19
   Compiling webpki v0.21.4
   Compiling sct v0.6.0
   Compiling rustls v0.16.0
   Compiling webpki-roots v0.18.0
   Compiling curltest v0.1.0 (C:\Users\Sam\Code\curltest)
    Finished dev [unoptimized + debuginfo] target(s) in 7.97s

// Using attohttpc
PS C:\Users\Sam\Code\curltest> cargo build
   Compiling tinyvec_macros v0.1.0
   Compiling matches v0.1.8
   Compiling autocfg v1.0.1
   Compiling winapi v0.3.9
   Compiling libc v0.2.81
   Compiling crc32fast v1.2.1
   Compiling cfg-if v1.0.0
   Compiling adler v0.2.3
   Compiling native-tls v0.2.6
   Compiling log v0.4.11
   Compiling lazy_static v1.4.0
   Compiling percent-encoding v2.1.0
   Compiling bytes v0.5.6
   Compiling itoa v0.4.6
   Compiling fnv v1.0.7
   Compiling cfg-if v0.1.10
   Compiling wildmatch v1.0.12
   Compiling tinyvec v1.1.0
   Compiling unicode-bidi v0.3.4
   Compiling form_urlencoded v1.0.0
   Compiling miniz_oxide v0.4.3
   Compiling http v0.2.1
   Compiling unicode-normalization v0.1.16
   Compiling flate2 v1.0.19
   Compiling idna v0.2.0
   Compiling url v2.2.0
   Compiling schannel v0.1.19
   Compiling attohttpc v0.16.0
   Compiling curltest v0.1.0 (C:\Users\Sam\Code\curltest)
    Finished dev [unoptimized + debuginfo] target(s) in 6.83s
remi-dupre commented 3 years ago

I was actually thinking of running curl binary directly from https://doc.rust-lang.org/std/process/struct.Command.html to avoid any dependency. It is less robust but I suppose it would be fine with a nice message asking to activate the standalone feature if curl is not found.