Liking cljdoc? Tell your friends :D

octet.core


allocateclj/s≠

clj

Polymorphic function for allocate new bytebuffers.

It allows allocate using different implementation of bytebuffers and different types of them.

As example, you may want allocate nio direct buffer of 4 bytes:

(allocate 4 {:type :direct :impl :nio})

The supported options pairs are:

  • type: :heap, impl: :nio (default)
  • type: :direct, impl: :nio
  • type: :heap, impl: :netty
  • type: :direct, impl: :netty
  • impl: :es6 (clojurescript) (default)

This function is defined as multimethod and you can extend it with your own bytebuffer implementations if you want or need it.

Polymorphic function for allocate new bytebuffers.

It allows allocate using different implementation
of bytebuffers and different types of them.

As example, you may want allocate nio direct buffer of 4 bytes:

    (allocate 4 {:type :direct :impl :nio})

The supported options pairs are:

- type: `:heap`, impl: `:nio` (default)
- type: `:direct`, impl: `:nio`
- type: `:heap`, impl: `:netty`
- type: `:direct`, impl: `:netty`
- impl: `:es6` (clojurescript) (default)

This function is defined as multimethod and you can
extend it with your own bytebuffer implementations
if you want or need it.
source (clj)source (cljs)raw docstring

boolclj/s≠

clj

Boolean type spec.

Boolean type spec.
source (clj)source (cljs)raw docstring

byteclj/s≠

clj

Byte type spec.

Byte type spec.
source (clj)source (cljs)raw docstring

bytesclj/s≠

clj
(bytes size)

Fixed size byte array type spec constructor.

Fixed size byte array type spec constructor.
cljs
source (clj)source (cljs)raw docstring

composeclj/s≠

clj
(compose constructor types)

Create a composed typespec with user defined type constructor.

This allows define a typespec with automatic conversion between user data type and serialized data without defining yourself a datatype using low level constructions.

Let see an exameple for understand it better.

Imagine you are have this data type:

(defrecord Point [x y])

With help of compose, create a new spec for your datatype:

(def point-spec (buf/compose ->Point [buf/int32 buf/int32]))

Now, you can use the previously defined datatype and typespec for write into buffer:

(buf/write! buffer mypoint point-spec)
;; => 8

Or read from the buffer:

(buf/read buffer (point))
;; => #user.Point{:x 1, :y 2}
Create a composed typespec with user defined
type constructor.

This allows define a typespec with automatic conversion
between user data type and serialized data without
defining yourself a datatype using low level constructions.

Let see an exameple for understand it better.

Imagine you are have this data type:

    (defrecord Point [x y])

With help of `compose`, create a new spec
for your datatype:

    (def point-spec (buf/compose ->Point [buf/int32 buf/int32]))

Now, you can use the previously defined datatype and typespec
for write into buffer:

    (buf/write! buffer mypoint point-spec)
    ;; => 8

Or read from the buffer:

    (buf/read buffer (point))
    ;; => #user.Point{:x 1, :y 2}
cljs
source (clj)source (cljs)raw docstring

doubleclj/s≠

clj

Double type spec.

Double type spec.
source (clj)source (cljs)raw docstring

floatclj/s≠

clj

Float type spec

Float type spec
source (clj)source (cljs)raw docstring

get-capacityclj/s≠

clj
(get-capacity _)

Get the read/write capacity in bytes.

Get the read/write capacity in bytes.
cljs
sourceraw docstring

int16clj/s≠

clj

Short type spec.

Short type spec.
source (clj)source (cljs)raw docstring

int32clj/s≠

clj

Integer type spec.

Integer type spec.
source (clj)source (cljs)raw docstring

int64clj/s≠

clj

Long type spec.

Long type spec.
source (clj)source (cljs)raw docstring

integerclj/s≠

clj

Integer type spec.

Integer type spec.
source (clj)source (cljs)raw docstring

intoclj/s

(into spec data)
(into spec data opts)

Returns a buffer of exact size of spec with data already serialized.

Returns a buffer of exact size of
spec with data already serialized.
sourceraw docstring

longclj/s≠

clj

Long type spec.

Long type spec.
source (clj)source (cljs)raw docstring

readclj/s

(read & args)

Read data from buffer following the specified spec instance. This function is a friend of read* and it returns only the readed data.

Read data from buffer following the specified
spec instance. This function is a friend of `read*`
and it returns only the readed data.
sourceraw docstring

read*clj/s

(read* buff spec)
(read* buff spec {:keys [offset] :or {offset 0}})

Read data from buffer following the specified spec instance.

This method returns a vector of readed data and the data itself. If you need only data, use read function instead.

Read data from buffer following the specified spec
instance.

This method returns a vector of readed data
and the data itself. If you need only data,
use `read` function instead.
sourceraw docstring

ref-bytesclj/s≠

clj
(ref-bytes ref-kw-or-index)

create a dynamic length byte array where the length of the byte array is stored in another spec within the containing indexed spec or associative spec. Example usages: (spec (int16) (int16) (ref-bytes* 1)) (spec :a (int16) :b (int32) (ref-bytes* :b)) where the first example would store the length of the byte array in the second int16 and the second example would store the length of the byte array in the int32 at key :b.

create a dynamic length byte array where the length of the byte array is stored in another
spec within the containing indexed spec or associative spec. Example usages:
(spec (int16) (int16) (ref-bytes* 1))
(spec :a (int16) :b (int32) (ref-bytes* :b))
where the first example would store the length of the byte array in the second int16 and
the second example would store the length of the byte array in the int32 at key :b.
cljs
source (clj)source (cljs)raw docstring

ref-stringclj/s≠

clj
(ref-string ref-kw-or-index)

create a dynamic length string where the length of the string is stored in another spec within the containing indexed spec or associative spec. Example usages: (spec (int16) (int16) (ref-string* 1)) (spec :a (int16) :b (int32) (ref-string* :b)) where the first example would store the length of the string in the second int16 and the second example would store the length of the string in the int32 at key :b.

create a dynamic length string  where the length of the string is stored in another
spec within the containing indexed spec or associative spec. Example usages:
(spec (int16) (int16) (ref-string* 1))
(spec :a (int16) :b (int32) (ref-string* :b))
where the first example would store the length of the string in the second int16 and
the second example would store the length of the string in the int32 at key :b.
cljs
source (clj)source (cljs)raw docstring

repeatclj/s≠

clj
(repeat n type)

Creare a composed typespec that repeats n times a provided type spec.

As example, create a spec with help of repeat function:

(def spec (buf/repeat 2 buf/int32))

Write data into buffer using previously defined typespec:

(buf/write! yourbuffer [200 300] spec)
;; => 8

Or read data from your buffer using previously defined typespec:

(buf/read yourbuffer spec)
;; => [200 300]
Creare a composed typespec that repeats `n` times
a provided `type` spec.

As example, create a spec with help of `repeat`
function:

    (def spec (buf/repeat 2 buf/int32))

Write data into buffer using previously defined
typespec:

    (buf/write! yourbuffer [200 300] spec)
    ;; => 8

Or read data from your buffer using previously defined
typespec:

    (buf/read yourbuffer spec)
    ;; => [200 300]
cljs
source (clj)source (cljs)raw docstring

shortclj/s≠

clj

Short type spec.

Short type spec.
source (clj)source (cljs)raw docstring

sizeclj/s≠

clj
(size _)

Calculate the size in bytes of the object.

Calculate the size in bytes of the object.
cljs
sourceraw docstring

specclj/s≠

clj
(spec & params)

Polymorphic constructor for Spec instances.

Spec is a some kind of composition of arbitrary number of types in associative or indexed data structure.

Little example on how to create associative composition:

(spec :field1 (long)
      :field2 (string 20))

An other example on how to create indexed composition that represents the same bytes representation that previous one:

(spec (long) (string 20))

The main difference between the two reprensentation is that if you read a buffer using an associative spec, the result will be clojure hash-map, and if indexed spec is used, the result will be clojure vector containing the values.

The same rules applies for writing data into a buffer.

Polymorphic constructor for Spec instances.

Spec is a some kind of composition of arbitrary
number of types in associative or indexed data
structure.

Little example on how to create associative
composition:

    (spec :field1 (long)
          :field2 (string 20))

An other example on how to create indexed
composition that represents the same bytes
representation that previous one:

    (spec (long) (string 20))

The main difference between the two reprensentation
is that if you read a buffer using an associative
spec, the result will be clojure hash-map, and if
indexed spec is used, the result will be clojure
vector containing the values.

The same rules applies for writing data into a
buffer.
cljs
source (clj)source (cljs)raw docstring

stringclj/s≠

clj
(string size)

Fixed length string type spec constructor.

Fixed length string type spec constructor.
cljs
source (clj)source (cljs)raw docstring

string*clj/s≠

clj

Arbitrary length string type spec.

Arbitrary length string type spec.
source (clj)source (cljs)raw docstring

ubyteclj/s≠

clj

Unsinged byte type spec.

Unsinged byte type spec.
source (clj)source (cljs)raw docstring

uint16clj/s≠

clj

Unsinged int16 type spec.

Unsinged int16 type spec.
source (clj)source (cljs)raw docstring

uint32clj/s≠

clj

Unsinged int32 type spec.

Unsinged int32 type spec.
source (clj)source (cljs)raw docstring

uint64clj/s≠

clj

Unsinged int64 type spec.

Unsinged int64 type spec.
source (clj)source (cljs)raw docstring

vector*clj/s≠

clj
(vector* t)

Create a arbitrary length (dynamic) array like typespec composition for t type.

Create a arbitrary length (dynamic) array like
typespec composition for `t` type.
cljs
source (clj)source (cljs)raw docstring

with-byte-ordercljmacro

(with-byte-order byteorder & body)
source

write!clj/s

(write! buff data spec)
(write! buff data spec {:keys [offset] :or {offset 0}})

Write data into buffer following the specified spec instance.

Write data into buffer following the specified
spec instance.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close