rbmarshal

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 6 Imported by: 1

README

ruby-marshal

Parse Ruby Marshal Binary Data.

go get github.com/dozen/ruby-marshal

Example

irb(main):001:0> Marshal.dump({ user: { name: "matsumoto-yasunori", age: 57 }, job: "voice-actor" }).unpack("H*")
=> ["04087b073a09757365727b073a096e616d654922176d617473756d6f746f2d796173756e6f7269063a0645543a08616765693e3a086a6f62492210766f6963652d6163746f72063b0754"]
b, _ := hex.DecodeString("04087b073a..(omit)..f72063b0754")
var v Profile
NewDecoder(bytes.NewReader(b)).Decode(&v)
#=> Profile{User:User{ Name:"matsumoto-yasunori", Age:57 }, Job:"voice-actor" }

Usage

Follow marshal_test.go.

Reference

Documentation

Index

Constants

View Source
const (
	SUPPORTED_MAJOR_VERSION = 4
	SUPPORTED_MINOR_VERSION = 8

	NIL_SIGN         = '0'
	TRUE_SIGN        = 'T'
	FALSE_SIGN       = 'F'
	FIXNUM_SIGN      = 'i'
	RAWSTRING_SIGN   = '"'
	SYMBOL_SIGN      = ':'
	SYMBOL_LINK_SIGN = ';'
	OBJECT_SIGN      = 'o'
	OBJECT_LINK_SIGN = '@'
	ARRAY_SIGN       = '['
	IVAR_SIGN        = 'I'
	HASH_SIGN        = '{'
	BIGNUM_SIGN      = 'l'
	REGEXP_SIGN      = '/'
	CLASS_SIGN       = 'c'
	MODULE_SIGN      = 'm'
)

Variables

This section is empty.

Functions

func MapToStruct

func MapToStruct(mi interface{}, o interface{})

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(v interface{}) error

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL