sing/common/rw/duplex.go
2022-05-23 10:44:50 +08:00

27 lines
417 B
Go

package rw
import (
"github.com/sagernet/sing/common"
)
type ReadCloser interface {
CloseRead() error
}
type WriteCloser interface {
CloseWrite() error
}
func CloseRead(reader any) error {
if c, ok := common.Cast[ReadCloser](reader); ok {
return c.CloseRead()
}
return nil
}
func CloseWrite(writer any) error {
if c, ok := common.Cast[WriteCloser](writer); ok {
return c.CloseWrite()
}
return nil
}