Files
tasks/chasm/path_encoder.go
Yichao YangandGitHub 89a4eb7855 CHASM: Engine Update/ReadComponent implementation (#7696)
## What changed?
- Implement chasm engine Update/Read Component method

## Why?
- CHASM work stream

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [x] added new unit test(s)
- [ ] added new functional test(s)
2025-05-08 19:21:27 -07:00

30 lines
661 B
Go

package chasm
import "strings"
var _ NodePathEncoder = (*defaultPathEncoder)(nil)
var DefaultPathEncoder NodePathEncoder = &defaultPathEncoder{}
type defaultPathEncoder struct{}
// TODO: Have a real implementation for DefaultPathEncoder
// that handles special characters in the path and support
// getting all immedidate children of a collection node.
func (e *defaultPathEncoder) Encode(
_ *Node,
path []string,
) (string, error) {
return strings.Join(path, "/"), nil
}
func (e *defaultPathEncoder) Decode(
encodedPath string,
) ([]string, error) {
if encodedPath == "" {
return []string{}, nil
}
return strings.Split(encodedPath, "/"), nil
}