struct Novika::Byteslice

Included Modules

Defined in:

novika/forms/byteslice.cr

Constant Summary

DEFAULT_PREVIEW = "byteslice"

Holds the default preview string for byteslices.

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Novika::Form

a(type : T.class) : T forall T a, desc(io : IO)
desc : String
desc
, die(details : String) die, effect(io)
effect
effect
, on_open(engine : Engine) : self on_open, on_parent_open(engine : Engine) : self on_parent_open, onto(block : Block) : self onto, sel(a, b) sel, to_quote : Quote to_quote

Instance methods inherited from module Novika::Schedulable

schedule(engine : Engine, stack : Block) schedule, schedule!(engine : Engine, stack : Block) schedule!

Constructor Detail

def self.new(bytes : Bytes, preview : String = DEFAULT_PREVIEW, mutable : Bool = true) #

Initializes a byteslice from bytes.


def self.new(io : IO, preview = DEFAULT_PREVIEW, mutable = true) #

Initializes a byteslice form from the given io.


def self.new(&) #

Yields an IO to the block, then returns a raw bytes form for it.


Class Method Detail

def self.typedesc #

Instance Method Detail

def ==(other : self) #

Two byteslices are equal when their content is equal, and their mutability statuses are equal.


def address #

Returns the memory address where this byteslice points to.


def at(b : Int32, e : Int32) #

Returns a sub-slice starting at b-th byte, and ending at e-th byte.

The resulting byteslice does not preserve the preview string of this byteslice.


def at(index : Int32) #

Returns the index-th byte.


def count #

Returns the amount of bytes in this byteslice.


def desc(io) #

def hash(hasher) #

Two byteslices are equal when their content is equal, and their mutability statuses are equal.


def mutable? : Bool #

Returns whether this byteslice is mutable.


def points_to?(address : UInt64) #

Returns whether this byteslice points to the given address.


def preview : String #

Returns the preview string of this byteslice.


def same?(other : Byteslice) #

Returns whether this and other byteslices point to the same location in memory, and have the same mutability status.


def to_io : IO::Memory #

Wraps the underlying byte slice in an IO.


def to_s(io) #

def to_unsafe : Bytes #

Returns the underlying byte slice.


def write_to(io : IO) #

Writes this byteslice to io.