Class: Extism::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/extism/manifest.rb

Overview

The manifest represents a recipe to build a plug-in. It generally consists of a path to one wasm module but could contain more. It also helps you define some options and restrictions on the runtime behavior of the plug-in. See extism.org/docs/concepts/manifest for more info.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Manifest

Initialize a manifest See extism.org/docs/concepts/manifest for schema

Parameters:

  • data (Hash)

    The Hash data that conforms the Manifest schema



64
65
66
# File 'lib/extism/manifest.rb', line 64

def initialize(data)
  @manifest_data = data
end

Instance Attribute Details

#manifest_dataObject (readonly)

Returns the value of attribute manifest_data.



8
9
10
# File 'lib/extism/manifest.rb', line 8

def manifest_data
  @manifest_data
end

Class Method Details

.from_bytes(data, hash: nil, name: nil) ⇒ Extism::Manifest

Create a manifest of a single wasm module with raw binary data. Look at #initialize for an interface with more control Consider using a file path instead of the raw wasm binary in memory. The performance is often better letting the runtime load the binary itself.

Parameters:

  • data (String)

    The binary data of the wasm module

  • hash (String | nil) (defaults to: nil)

    An optional sha256 integrity hash. Defaults to nil

  • name (String | nil) (defaults to: nil)

    An optional name. Defaults to nil

Returns:

See Also:

  • Manifest::initialize


52
53
54
55
56
57
58
# File 'lib/extism/manifest.rb', line 52

def self.from_bytes(data, hash: nil, name: nil)
  wasm = { data: data }
  wasm[:hash] = hash unless hash.nil?
  wasm[:name] = name unless hash.nil?

  Manifest.new({ wasm: [wasm] })
end

.from_path(path, hash: nil, name: nil) ⇒ Extism::Manifest

Create a manifest of a single wasm from file path. Look at #initialize for an interface with more control

Parameters:

  • path (String)

    The path to the wasm module on disk

  • hash (String | nil) (defaults to: nil)

    An optional sha256 integrity hash. Defaults to nil

  • name (String | nil) (defaults to: nil)

    An optional name. Defaults to nil

Returns:

See Also:

  • Manifest::initialize


34
35
36
37
38
39
40
# File 'lib/extism/manifest.rb', line 34

def self.from_path(path, hash: nil, name: nil)
  wasm = { path: path }
  wasm[:hash] = hash unless hash.nil?
  wasm[:name] = name unless hash.nil?

  Manifest.new({ wasm: [wasm] })
end

.from_url(url, hash: nil, name: nil) ⇒ Extism::Manifest

Create a manifest of a single wasm from url. Look at #initialize for an interface with more control

Parameters:

  • url (String)

    The url to the wasm module

  • hash (String | nil) (defaults to: nil)

    An optional sha256 integrity hash. Defaults to nil

  • name (String | nil) (defaults to: nil)

    An optional name. Defaults to nil

Returns:

See Also:

  • Manifest::initialize


18
19
20
21
22
23
24
# File 'lib/extism/manifest.rb', line 18

def self.from_url(url, hash: nil, name: nil)
  wasm = { url: url }
  wasm[:hash] = hash unless hash.nil?
  wasm[:name] = name unless hash.nil?

  Manifest.new({ wasm: [wasm] })
end