scodec-stream


License

License

GroupId

GroupId

org.scodec
ArtifactId

ArtifactId

scodec-stream_2.11
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

scodec-stream
scodec-stream
Project URL

Project URL

http://github.com/scodec/scodec-stream
Project Organization

Project Organization

org.scodec
Source Code Management

Source Code Management

https://github.com/scodec/scodec-stream

Download scodec-stream_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/org.scodec/scodec-stream_2.11/ -->
<dependency>
    <groupId>org.scodec</groupId>
    <artifactId>scodec-stream_2.11</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.scodec/scodec-stream_2.11/
implementation 'org.scodec:scodec-stream_2.11:2.0.0'
// https://jarcasting.com/artifacts/org.scodec/scodec-stream_2.11/
implementation ("org.scodec:scodec-stream_2.11:2.0.0")
'org.scodec:scodec-stream_2.11:jar:2.0.0'
<dependency org="org.scodec" name="scodec-stream_2.11" rev="2.0.0">
  <artifact name="scodec-stream_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.scodec', module='scodec-stream_2.11', version='2.0.0')
)
libraryDependencies += "org.scodec" % "scodec-stream_2.11" % "2.0.0"
[org.scodec/scodec-stream_2.11 "2.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
org.scodec : scodec-core_2.11 jar 1.11.4
co.fs2 : fs2-core_2.11 jar 2.0.0

Project Modules

There are no modules declared in this project.

scodec-stream

Scodec-stream is a library for streaming binary encoding and decoding. It is built atop scodec and fs2. Here's a brief example of its use:

import scodec.codecs._
import scodec.stream._
import scodec.bits._
import cats.effect.{Blocker, IO}
import fs2.Stream

val frames: StreamDecoder[ByteVector] = StreamDecoder.many(int32)
 .flatMap { numBytes => StreamDecoder.once(bytes(numBytes)) }

val filePath = java.nio.file.Paths.get("path/to/file")

val s: Stream[IO, ByteVector] =
  Stream.resource(Blocker[IO]).flatMap { blocker =>
    fs2.io.file.readAll[IO](filePath, blocker, 4096).through(frames.toPipeByte)
  }

When consumed, s will incrementally read chunks from "largefile.bin", then decode a stream of frames, where each frame is expected to begin with a number of bytes specified as a 32-bit signed int (the int32 codec), followed by a frame payload of that many bytes. Nothing happens until the s stream is consumed, and s will ensure the file is closed in the event of an error or normal termination of the consumer.

See the MPEG PCAP decoding example for a more sophisticated use case.

Links:

Administrative

This project is licensed under a 3-clause BSD license.

People are expected to follow the Typelevel Code of Conduct when discussing scodec on the Github page, Gitter channel, mailing list, or other venues.

Concerns or issues can be sent to Michael Pilquist ([email protected]) or to Typelevel.

Getting Binaries

See the releases page on the website.

Code of Conduct

See the Code of Conduct.

org.scodec
Scala combinator library for working with binary data.

Versions

Version
2.0.0
1.2.1
1.2.0
1.2.0-RC2
1.2.0-RC1
1.1.0
1.1.0-RC2
1.1.0-M10
1.1.0-M9
1.1.0-M8
1.1.0-M6
1.1.0-M4
1.1.0-M3
1.1.0-M2
1.0.1
1.0.0
1.0.0-RC2
1.0.0-RC1
1.0.0-M6
1.0.0-M5
1.0.0-M4
1.0.0-M3
1.0.0-M2a
1.0.0-M2
1.0.0-M1
0.12.0-a
0.12.0
0.11.0
0.10.0
0.9.0
0.8.0
0.7.1
0.7.0