4. Split converters
This commit is contained in:
parent
87c78566c1
commit
c05d4fe951
61
internal/fusefs/converters.go
Normal file
61
internal/fusefs/converters.go
Normal 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
|
||||
}
|
||||
|
||||
|
@ -8,63 +8,10 @@ import (
|
||||
"syscall"
|
||||
"github.com/hanwen/go-fuse/v2/fs"
|
||||
"github.com/hanwen/go-fuse/v2/fuse"
|
||||
"strconv"
|
||||
"io"
|
||||
"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 {
|
||||
name string
|
||||
Ino uint64
|
||||
|
Loading…
Reference in New Issue
Block a user