Skip to content

MinervasRefuge/Guile-Snappy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guile-Snappy

A Guile FFI for Google’s 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.

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

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.

(uncompress bv-compressed
            #:key
            (compressed-offset 0)
             compressed-length)

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.

(validate-compressed bv-compressed
                     #:key
                     (compressed-offset 0)
                      compressed-length)

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:

… 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

It will return a boolean on valid or invalid compression.

(uncompressed-length bv-compressed
                     #:key
                     (compressed-offset 0)
                      compressed-length 

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.

About

Guile FFI for Google's Snappy compression library.

Topics

Resources

License

Stars

Watchers

Forks