Coder Social home page Coder Social logo

scodec-bits's Introduction

scodec-bits

Provides persistent datatypes for working with bits and bytes.

Design Constraints

  • No dependencies on other libraries in order to be applicable to as many projects as possible.

Introduction

There are two fundamental data structures provided:

Both datatypes provide collection like functionality, although neither directly implement the Scala collection library traits. Both are implemented as binary trees where each node is either a leaf node containing bits/bytes or is an inner node containing an operation on other trees (e.g., append). As a result, many operations are implemented in logarithmic time with respect to the depth of the tree.

Both strict and lazy constructors are provided. Of particular interest are the methods that work with Java NIO sources like java.nio.channels.ReadableByteChannel and java.nio.channels.FileChannel, which allow efficient, lazy access and manipulation of bits and bytes from a variety of sources.

Hexadecimal and binary string literals are supported via the hex and bin string interpolators. For example:

val x: ByteVector = hex"deadbeef"
val y: BitVector = bin"00101101010010101"

Base conversions to and from strings are supported. Binary, hexadecimal, and base 64 conversions are supported. Each have a default alphabet but support alternative alphabets as well as user defined alphabets.

For more information, see the API documentation.

For a combinator based approach to encoding values to/from binary, see the companion project scodec.

Getting Binaries

This library works with Scala 2.10 and 2.11.

Releases

The latest released version is 1.0.4.

For SBT users:

libraryDependencies += "org.typelevel" %% "scodec-bits" % "1.0.4"

For Maven users:

<dependencies>
  <dependency>
    <groupId>org.typelevel</groupId>
    <artifactId>scodec-bits_2.11</artifactId>
    <version>1.0.4</version>
  </dependency>
</dependencies>

Snapshots

Snapshot builds of the master branch are available on Sonatype's OSS hosting at https://oss.sonatype.org/content/repositories/snapshots/.

For SBT users:

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"

libraryDependencies += "org.typelevel" %% "scodec-bits" % "1.1.0-SNAPSHOT"

For Maven users:

<repositories>
  <repository>
    <id>sonatype-oss-snapshots</id>
    <name>Sonatype OSS Snapshots</name>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>org.typelevel</groupId>
    <artifactId>scodec-bits_2.10</artifactId>
    <version>1.1.0-SNAPSHOT</version>
  </dependency>
</dependencies>

Building

This project uses sbt. To build, run sbt publish-local.

scodec-bits's People

Contributors

mpilquist avatar pchiusano avatar vptheron avatar bryce-anderson avatar rossabaker avatar

Watchers

David Barri avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.