fifo

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(closable bool) (uint32, io.WriteCloser)

New creates a new fifo. Fifo is always closable by the creator, but only closable by accessor if closable is set to true.

Example
package main

import (
	"fmt"
	"io"

	symbols "github.com/taubyte/go-sdk-symbols/i2mv/fifo"
	"github.com/taubyte/go-sdk/i2mv/fifo"
)

var (
	writeCloser io.WriteCloser
	id          uint32
)

func main() {
	// Mocking the calls to the vm for usage in tests and playground
	symbols.MockNew(1)
	symbols.MockPush(1)

	id, writeCloser = fifo.New(true)
	if id != 1 {
		fmt.Printf("expected id `1` got `%d`", id)
		return
	}

	n, err := writeCloser.Write([]byte("hello world"))
	if err != nil {
		fmt.Printf("writing to fifo failed with: %s\n", err)
		return
	}

	fmt.Println(n)
}
Output:

11

Types

type Fifo

type Fifo interface {
	io.ReadCloser
	Id() uint32
}

TODO: Move to Interfaces once it is open sourced

func Open

func Open(id uint32) (Fifo, error)
Example
package main

import (
	"fmt"

	symbols "github.com/taubyte/go-sdk-symbols/i2mv/fifo"
	"github.com/taubyte/go-sdk/i2mv/fifo"
)

func main() {
	// Mocking the calls to the vm for usage in tests and playground
	symbols.MockOpen(2, true)

	ff, err := fifo.Open(2)
	if err != nil {
		fmt.Printf("error opening fifo with: %s\n", err)
		return
	}

	fmt.Println(ff.Id())
}
Output:

2

Jump to

Keyboard shortcuts

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