Module: IsccLib

Defined in:
lib/iscc_lib/version.rb,
lib/iscc_lib.rb

Overview

Version constant for the iscc-lib gem (synced from root Cargo.toml).

Defined Under Namespace

Classes: AudioCodeResult, DataCodeResult, DataHasher, IdCodeResult, ImageCodeResult, InstanceCodeResult, InstanceHasher, IsccCodeResult, MetaCodeResult, MixedCodeResult, Result, SumCodeResult, TextCodeResult, VideoCodeResult

Constant Summary collapse

VERSION =
"0.6.0"

Class Method Summary collapse

Class Method Details

.gen_audio_code_v0(cv, bits: 64) ⇒ AudioCodeResult

Generate an Audio-Code from a Chromaprint feature vector.

Parameters:

  • cv (Array<Integer>)

    Chromaprint fingerprint integers

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

Returns:



103
104
105
# File 'lib/iscc_lib.rb', line 103

def self.gen_audio_code_v0(cv, bits: 64)
  AudioCodeResult[_gen_audio_code_v0(cv, bits)]
end

.gen_data_code_v0(data, bits: 64) ⇒ DataCodeResult

Generate a Data-Code from binary data.

Parameters:

  • data (String)

    binary data

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

Returns:



130
131
132
# File 'lib/iscc_lib.rb', line 130

def self.gen_data_code_v0(data, bits: 64)
  DataCodeResult[_gen_data_code_v0(data, bits)]
end

.gen_image_code_v0(pixels, bits: 64) ⇒ ImageCodeResult

Generate an Image-Code from pixel data.

Parameters:

  • pixels (String)

    binary pixel data

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

Returns:



94
95
96
# File 'lib/iscc_lib.rb', line 94

def self.gen_image_code_v0(pixels, bits: 64)
  ImageCodeResult[_gen_image_code_v0(pixels, bits)]
end

.gen_instance_code_v0(data, bits: 64) ⇒ InstanceCodeResult

Generate an Instance-Code from binary data.

Parameters:

  • data (String)

    binary data

  • bits (Integer) (defaults to: 64)

    bit length (default: 64, accepted for API consistency)

Returns:



139
140
141
# File 'lib/iscc_lib.rb', line 139

def self.gen_instance_code_v0(data, bits: 64)
  InstanceCodeResult[_gen_instance_code_v0(data, bits)]
end

.gen_iscc_code_v0(codes, wide: false) ⇒ IsccCodeResult

Generate a composite ISCC-CODE from individual unit codes.

Parameters:

  • codes (Array<String>)

    ISCC unit strings (Data-Code + Instance-Code, optional Content-Code)

  • wide (Boolean) (defaults to: false)

    use 256-bit combination (default: false for 128-bit)

Returns:



148
149
150
# File 'lib/iscc_lib.rb', line 148

def self.gen_iscc_code_v0(codes, wide: false)
  IsccCodeResult[_gen_iscc_code_v0(codes, wide)]
end

.gen_iscc_id_v1(timestamp, hub_id, realm) ⇒ IdCodeResult

Generate an ISCC-IDv1 from a timestamp and a HUB-ID (experimental).

Packs a 52-bit microsecond UTC timestamp and a 12-bit HUB-ID into an ISCC-ID unit with realm as SubType and Version V1. There is no dedicated decoder — use iscc_decode to decode.

Parameters:

  • timestamp (Integer)

    microsecond UTC timestamp (0 <= timestamp < 2^52)

  • hub_id (Integer)

    HUB-ID (0 <= hub_id < 4096)

  • realm (Integer)

    realm (0 = testnet, 1 = mainnet)

Returns:

Raises:

  • (RuntimeError)

    if any parameter is negative or out of range



174
175
176
# File 'lib/iscc_lib.rb', line 174

def self.gen_iscc_id_v1(timestamp, hub_id, realm)
  IdCodeResult[_gen_iscc_id_v1(timestamp, hub_id, realm)]
end

.gen_meta_code_v0(name, description: nil, meta: nil, bits: 64) ⇒ MetaCodeResult

Generate a Meta-Code from name and optional metadata.

Parameters:

  • name (String)

    content name (required, non-empty)

  • description (String, nil) (defaults to: nil)

    optional content description

  • meta (String, nil) (defaults to: nil)

    optional JSON metadata

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

Returns:

  • (MetaCodeResult)

    hash with iscc, name, metahash, and optionally description, meta



76
77
78
# File 'lib/iscc_lib.rb', line 76

def self.gen_meta_code_v0(name, description: nil, meta: nil, bits: 64)
  MetaCodeResult[_gen_meta_code_v0(name, description, meta, bits)]
end

.gen_mixed_code_v0(codes, bits: 64) ⇒ MixedCodeResult

Generate a Mixed-Code from multiple ISCC content code strings.

Parameters:

  • codes (Array<String>)

    ISCC unit strings

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

Returns:



121
122
123
# File 'lib/iscc_lib.rb', line 121

def self.gen_mixed_code_v0(codes, bits: 64)
  MixedCodeResult[_gen_mixed_code_v0(codes, bits)]
end

.gen_sum_code_v0(path, bits: 64, wide: false, add_units: false) ⇒ SumCodeResult

Generate a composite ISCC-CODE from a file in a single pass.

Parameters:

  • path (String)

    file path

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

  • wide (Boolean) (defaults to: false)

    use 256-bit combination (default: false)

  • add_units (Boolean) (defaults to: false)

    include individual unit codes (default: false)

Returns:

  • (SumCodeResult)

    hash with iscc, datahash, filesize, and optionally units



159
160
161
# File 'lib/iscc_lib.rb', line 159

def self.gen_sum_code_v0(path, bits: 64, wide: false, add_units: false)
  SumCodeResult[_gen_sum_code_v0(path, bits, wide, add_units)]
end

.gen_text_code_v0(text, bits: 64) ⇒ TextCodeResult

Generate a Text-Code from plain text content.

Parameters:

  • text (String)

    plain text content

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

Returns:



85
86
87
# File 'lib/iscc_lib.rb', line 85

def self.gen_text_code_v0(text, bits: 64)
  TextCodeResult[_gen_text_code_v0(text, bits)]
end

.gen_video_code_v0(frame_sigs, bits: 64) ⇒ VideoCodeResult

Generate a Video-Code from frame signature vectors.

Parameters:

  • frame_sigs (Array<Array<Integer>>)

    nested array of frame signatures

  • bits (Integer) (defaults to: 64)

    bit length (default: 64)

Returns:



112
113
114
# File 'lib/iscc_lib.rb', line 112

def self.gen_video_code_v0(frame_sigs, bits: 64)
  VideoCodeResult[_gen_video_code_v0(frame_sigs, bits)]
end