Nim implementation of Snappy compression algorithm
Go to file
Jacek Sieka 16bf7b7d96
deduplicate and reorganise code (#9)
The snappy codebase is a mess with competing implementations,
nonsensical code duplication and no real direction due to a partially
implemented faststreams migration.

This PR makes it slightly less of a mess, but make no mistake, it's
still a mess - the difference being that there are a few more signposts
along the way in terms of module organisation, and a little less mess as
the line count of the PR discloses.

Performance remains poor - ~3x slower than C++ - but at least there's
less code to look at :)
2022-04-01 12:57:39 +02:00
.github/workflows CI: test with multiple Nim versions (#7) 2022-01-11 20:25:13 +01:00
snappy deduplicate and reorganise code (#9) 2022-04-01 12:57:39 +02:00
tests deduplicate and reorganise code (#9) 2022-04-01 12:57:39 +02:00
.appveyor.yml add github action script 2020-12-22 15:27:06 +07:00
.gitattributes renormalize *.txt EOL 2020-04-01 22:35:57 +03:00
.gitignore submoduling snappycpp 2020-12-22 12:17:39 +07:00
.gitmodules submoduling snappycpp 2020-12-22 12:17:39 +07:00
.travis.yml fixes ci script 2020-12-22 12:34:07 +07:00
LICENSE initial commit 2018-11-02 12:10:58 +07:00
README.md CI: refactor Nim compiler caching 2021-06-01 04:05:29 +02:00
snappy.nim deduplicate and reorganise code (#9) 2022-04-01 12:57:39 +02:00
snappy.nimble deduplicate and reorganise code (#9) 2022-04-01 12:57:39 +02:00

README.md

Snappy

Build Status Build status nimble license Github action

Nim implementation of Snappy compression algorithm

Currently, this implementation only support block compression and no stream compression support at all.

API

  • proc encode*(src: openArray[byte]): seq[byte]
  • proc decode*(src: openArray[byte]): seq[byte]
  • template compress --- an alias to encode
  • template uncompress --- an alias to decode

Examples

import snappy
var source = readFile("readme.md")
var encoded = snappy.encode(toOpenArrayByte(source, 0, source.len-1))
var decoded = snappy.decode(encoded)
assert equalMem(decoded[0].addr, source[0].addr, source.len)

Installation via nimble

nimble install snappy