These are chat archives for rust-lang/rust

26th
Mar 2016
hi!
is there some high-level library for uncompressing zip files?
the crates I found were all extremely low-level.
I'm basically looking for a function unzip(reader, writer)
Konstantin Stepanov
@kstep
Mar 26 2016 17:51
@soc I guess you need https://crates.io/crates/zip
@kstep yes, that's one crate I considered.
I could write code to drive the low-level library, but I'm concerned that some weird zip file could create a huge mess if I handle all the logic myself ...
I'm wondering: why are some crates published on https://doc.rust-lang.org/ while others are not?
Pete Hayes
@petehayes102
Mar 26 2016 18:36
doc.rust-lang.org is for the std lib
anything that isn’t stdlib won’t be on there
(e.g. third party crates)
so does https://doc.rust-lang.org/time/time/index.html belong to the std library?
I'm kind of confused about it. It looks kind of official, but the insides smell like some low-level C struct-level interop library.
Pete Hayes
@petehayes102
Mar 26 2016 18:38
heh…nope. i stand corrected!
maybe the better way to put it is official crates, as you said
you can probably correlate doc.rust-lang.org crates with repos on their github account
that's scary ... I think https://doc.rust-lang.org/time/time/struct.Tm.html is a great example of what's wrong about coyping C/Unix/Linux stuff verbatim.
Pete Hayes
@petehayes102
Mar 26 2016 18:40
how so?
and the "damn, my 64kB hard-drive ran out of space! better save two letters in naming my time struct" isn't the worst part
the confusion about what's 0-based and what's 1-based. plus the "a calendar date..." is completely meaningless without specifying the chronology and the actual calendar used.
Pete Hayes
@petehayes102
Mar 26 2016 18:43
i can’t speak to the time crate specifically, but it seems you might be looking for something higher level, like java?
it's true that the java.time package got a lot of things right in that regard, but I think it's not a thing about languages, but about providing libraries.
Pete Hayes
@petehayes102
Mar 26 2016 18:46
perhaps. rust is a very new language. i’m surprised that the ecosystem is as rich as it is considering its age.
Erik Hedvall
@Ogeon
Mar 26 2016 18:46
I'm not 100% sure, but I think the time crate may actually be a wrapper around a C library
Kevin K.
@kbknapp
Mar 26 2016 18:46
I think youre absolutely right @soc becauae Rust does have some higher level style libs, but its only in the infancy of this so far
I have seen a few other date/time libraries in Rust which seem to copy Java quite a bit.
(but I think they also skip the calendar/chronology part)
which is kind of promising
(ported the reference implementation of java.time to Scala for compilation to Javascript ... saw a lot of horribly complex, but necessary code in that package)
it's like a few straightforward combinations of date, time and zones, and the screaming madness of handling leapseconds, zone transitions, dsts, different calendaring systems and chronologies.
Peter Atashian
@retep998
Mar 26 2016 20:08
@soc time is basically a straight wrapper around C standard library time (except on Windows where it calls system functions to get similar behavior)
Konstantin Stepanov
@kstep
Mar 26 2016 20:15
@soc there's no really problem with zip crate, as ZipFile implements Read trait, so once you got ZipFile you just copy it to output file.
Konstantin Stepanov
@kstep
Mar 26 2016 20:22
(0..zip.len()).map(|i| zip.by_index(i)).map(|mut f| copy(&mut f, File::create(f.name()))).count() should do the main work (haven't checked it actually, borrow checker may frown upon the code and no subdirectories handled)
Kevin K.
@kbknapp
Mar 26 2016 20:25
Thats a bit of a far cry from zip(reader, writer) :P
@kstep what I'm wondering is how the zip's dir structure is preserved
my concern is that while writing that on my own is certainly an option, I'm subscribing to handling all the edge cases (like symbolic links) myself
Konstantin Stepanov
@kstep
Mar 26 2016 20:29
@soc I don't see another solution here, sorry.