mirror of
https://github.com/hanzoai/numscript.git
synced 2026-10-30 18:26:57 +00:00
* feat: feature flag syntax * feat: change syntax * feat: reject invalid features * feat: add static check of unknown features * feat: more defensive args handling * fix: fix typo
32 lines
560 B
Go
32 lines
560 B
Go
package jsonrpc2
|
|
|
|
// This is mostly intented as a testing utility
|
|
type ChanObjStream struct {
|
|
in <-chan Message
|
|
out chan<- Message
|
|
}
|
|
|
|
var _ MessageStream = (*ChanObjStream)(nil)
|
|
|
|
func NewChanObjStream(in <-chan Message, out chan<- Message) *ChanObjStream {
|
|
return &ChanObjStream{
|
|
in: in,
|
|
out: out,
|
|
}
|
|
}
|
|
|
|
func (c *ChanObjStream) Close() error {
|
|
close(c.out)
|
|
return nil
|
|
}
|
|
|
|
func (c *ChanObjStream) ReadMessage() (Message, error) {
|
|
msg := <-c.in
|
|
return msg, nil
|
|
}
|
|
|
|
func (c *ChanObjStream) WriteMessage(obj Message) error {
|
|
c.out <- obj
|
|
return nil
|
|
}
|