4. Split converters

This commit is contained in:
Yannick Ulrich 2023-03-01 15:15:32 +00:00
parent 87c78566c1
commit c05d4fe951
2 changed files with 61 additions and 53 deletions

View File

@ -0,0 +1,61 @@
package fusefs
import (
"go.arsenm.dev/infinitime"
"context"
"strconv"
)
func converterU8(ctx context.Context, in <-chan uint8) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event)) + "\n")
}
}
}()
return out
}
func converterU32(ctx context.Context, in <-chan uint32) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event)) + "\n")
}
}
}()
return out
}
func converterMotionValues(ctx context.Context, in <-chan infinitime.MotionValues) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event.X)) + " " + strconv.Itoa(int(event.Y)) + " " + strconv.Itoa(int(event.Z)) + "\n")
}
}
}()
return out
}
func converter1String(ctx context.Context, in string) <-chan []byte {
out := make(chan []byte, 2)
out <- []byte(in + "\n")
close(out)
return out
}

View File

@ -8,63 +8,10 @@ import (
"syscall" "syscall"
"github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fs"
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
"strconv"
"io" "io"
"bytes" "bytes"
) )
func converterU8(ctx context.Context, in <-chan uint8) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event)) + "\n")
}
}
}()
return out
}
func converterU32(ctx context.Context, in <-chan uint32) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event)) + "\n")
}
}
}()
return out
}
func converterMotionValues(ctx context.Context, in <-chan infinitime.MotionValues) <-chan []byte {
out := make(chan []byte, 2)
go func() {
for {
select {
case <- ctx.Done():
return
case event := <-in:
out <- []byte(strconv.Itoa(int(event.X)) + " " + strconv.Itoa(int(event.Y)) + " " + strconv.Itoa(int(event.Z)) + "\n")
}
}
}()
return out
}
func converter1String(ctx context.Context, in string) <-chan []byte {
out := make(chan []byte, 2)
out <- []byte(in + "\n")
close(out)
return out
}
type ITProperty struct { type ITProperty struct {
name string name string
Ino uint64 Ino uint64