guzba / zippy

Pure Nim implementation of deflate, zlib, gzip and zip.
MIT License
258 stars 31 forks source link

Expose types #63

Closed konsumer closed 1 year ago

konsumer commented 1 year ago

This may be an issue with me being new to nim, but if I want to keep a reference to a ZipArchiveReader it's not exposed:

import zippy

type
  Null0Game* = object
    files*: ZipArchiveReader

proc newNull0Game*(filename: string): Null0Game =
  ## Create a new Game instance
  var game: Null0Game
  game.files = openZipArchive(filename)
  return game

I get undeclared identifier: 'ZipArchiveReader'. I think it just needs a few * to allow type-reference.

I am happy to PR for this, if this is the right way.

guzba commented 1 year ago

Zippy does not export zip stuff by default (nor tarball stuff), you'll want to import zippy/ziparchives.

konsumer commented 1 year ago

Sorry, my example was incomplete. I think I forgot to write the rest of it. I am importing zippy/ziparchives but the types are not exported, so cannot be referenced. Here is a more complete example:

import zippy/ziparchives

type
  Null0Game* = object
    files*: ZipArchiveReader

proc newNull0Game*(filename: string): Null0Game =
  ## Create a new Game instance
  var game: Null0Game
  game.files = openZipArchive(filename)
  return game

Since zippy/ziparchives doesn't export ZipArchiveReader (only openZipArchive) I can't reference the type.

Like, I can do this:

var reader = openZipArchive("cool.zip")

but not

var reader:ZipArchiveReader = openZipArchive("cool.zip")
guzba commented 1 year ago

Ah I see, yeah ZipArchiveReader should be exported. Doing that quick here https://github.com/guzba/zippy/pull/64

konsumer commented 1 year ago

Yep, sorry for the lack of clarity.

guzba commented 1 year ago

Tagged as release 0.10.10, should be good to go!