An open API service indexing awesome lists of open source software.

https://github.com/minervasrefuge/guile-snappy

Guile FFI for Google's Snappy compression library.
https://github.com/minervasrefuge/guile-snappy

ffi guile guile-scheme snappy

Last synced: about 2 months ago
JSON representation

Guile FFI for Google's Snappy compression library.

Awesome Lists containing this project

README

        

#+OPTIONS: toc:nil
#+OPTIONS: ^:nil

* Guile-Snappy
A [[https://www.gnu.org/software/guile/][Guile]] FFI for Google's [[https://github.com/google/snappy][Snappy]] compression library. (~snappy-c.h~ bindings only).

** Detailed Docs
Recommended import style...
- ~(use-modules ((snappy) #:prefix snappy:))~
- ~(define-module (...) #:use-module ((snappy) #:prefix snappy:))~

*** Functions
Note: Fn signatures abbreviated here.

#+BEGIN_SRC scheme
(compress bv-uncompressed
#:key
(uncompressed-offset 0)
uncompressed-length
(trim-compressed? #t))
#+END_SRC

Produces a compressed version of ~bv-uncompressed~ (/bytevector/) at the ~uncompressed-offset~ (/integer/) position with the specified length ~uncompressed-length~ (/integer/). By default it will use the entire /bytevector/ range.

It will return a compressed /bytevector/. If ~trim-compressed?~ is ~#f~, then it shall be two values, the compressed /bytevector/ and the length (/integer/) of the compressed buffer used.

#+BEGIN_SRC scheme
(uncompress bv-compressed
#:key
(compressed-offset 0)
compressed-length)
#+END_SRC

Produces a uncompressed version of ~bv-compressed~ (/bytevector/) at the ~compressed-offset~ (/integer/) position with the specified length ~compressed-length~ (/integer/). By default it will use the entire /bytevector/ range.

It will return a uncompressed /bytevector/.

#+BEGIN_SRC scheme
(validate-compressed bv-compressed
#:key
(compressed-offset 0)
compressed-length)
#+END_SRC

Checks ~bv-compressed~ (/bytevector/) at the ~compressed-offset~ (/integer/) with the specified length ~compressed-length~ (/integer/) for a valid Snappy compression. As per Snappy documentation:
#+BEGIN_QUOTE
... Takes time proportional to compressed_length, but is usually at least a factor of four faster than actual decompression. --- snappy_validate_compressed_buffer :: snappy-c.h
#+END_QUOTE

It will return a /boolean/ on valid or invalid compression.

#+BEGIN_SRC scheme
(uncompressed-length bv-compressed
#:key
(compressed-offset 0)
compressed-length
#+END_SRC

Produces the maximum uncompressed /bytevector/ length needed to decompress ~bv-compressed~ (/bytevector/) at ~compressed-offset~ (/integer/) for the specified length ~compressed-length~ (/integer/). Probably not something you'll need with the current Guile interface.

*** Exceptions
Any of the above functions may produce the following errors, unless noted otherwise...
- ~<&compound-exception <&programming-error> ...>~ :: Produced on invalid input types.
- ~<&snappy-invalid-input>~ :: Usually produced on buffer range or bad data issues.
- ~<&snappy-buffer-too-small-exception>~ :: Produced if the output buffer is too small, (unlikely to occur with the current API).

The above ~&snappy-*~ exceptions inherits from a parent type ~&snappy-exception~ and ~&exception~.