Przeglądaj źródła

codec: document encWriter and decReader interfaces

Ugorji Nwoke 6 lat temu
rodzic
commit
1c309c2bcc
2 zmienionych plików z 7 dodań i 15 usunięć
  1. 5 8
      codec/reader.go
  2. 2 7
      codec/writer.go

+ 5 - 8
codec/reader.go

@@ -5,20 +5,18 @@ package codec
 
 import "io"
 
-/*
-
 // decReader abstracts the reading source, allowing implementations that can
 // read from an io.Reader or directly off a byte slice with zero-copying.
-//
-// Deprecated: Use decRd instead.
 type decReader interface {
 	unreadn1()
 	// readx will use the implementation scratch buffer if possible i.e. n < len(scratchbuf), OR
 	// just return a view of the []byte being decoded from.
 	// Ensure you call detachZeroCopyBytes later if this needs to be sent outside codec control.
-	readx(n int) []byte
+	readx(n uint) []byte
 	readb([]byte)
 	readn1() uint8
+	readn3() [3]byte
+	readn4() [4]byte
 	numread() uint // number of bytes read
 	track()
 	stopTrack() []byte
@@ -31,8 +29,6 @@ type decReader interface {
 	readUntil(stop byte) (out []byte)
 }
 
-*/
-
 // ------------------------------------------------
 
 type unreadByteStatus uint8
@@ -1327,6 +1323,7 @@ func (z *decRd) readUntilIO(stop byte) (out []byte) {
 	return z.ri.readUntil(stop)
 }
 
+var _ decReader = (*decRd)(nil)
+
 // // register these here, so that staticcheck stops barfing
-// var _ = (*bytesDecReader).readTo
 // var _ = (*bytesDecReader).readUntil

+ 2 - 7
codec/writer.go

@@ -5,12 +5,7 @@ package codec
 
 import "io"
 
-/*
-
 // encWriter abstracts writing to a byte array or to an io.Writer.
-//
-//
-// Deprecated: Use encWr instead.
 type encWriter interface {
 	writeb([]byte)
 	writestr(string)
@@ -20,8 +15,6 @@ type encWriter interface {
 	end()
 }
 
-*/
-
 // type ioEncWriterWriter interface {
 // 	WriteByte(c byte) error
 // 	WriteString(s string) (n int, err error)
@@ -488,3 +481,5 @@ func (z *encWr) end() {
 }
 
 */
+
+var _ encWriter = (*encWr)(nil)