Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec struct{}
Codec is a Codec[[]byte] backed by encoding/ascii85. It is safe for concurrent use.
func NewCodec ¶
func NewCodec() *Codec
NewCodec returns an ASCII85 serializer.
Example ¶
package main
import (
"fmt"
"github.com/foomo/goencode/ascii85"
)
func main() {
c := ascii85.NewCodec()
encoded, err := c.Encode([]byte("hello"))
if err != nil {
fmt.Printf("Encode failed: %v\n", err)
return
}
fmt.Printf("Encoded: %s\n", string(encoded))
var decoded []byte
if err := c.Decode(encoded, &decoded); err != nil {
fmt.Printf("Decode failed: %v\n", err)
return
}
fmt.Printf("Decoded: %s\n", string(decoded))
}
Output: Encoded: BOu!rDZ Decoded: hello
type StreamCodec ¶
type StreamCodec struct{}
StreamCodec is a StreamCodec[[]byte] backed by encoding/ascii85. It is safe for concurrent use.
func NewStreamCodec ¶
func NewStreamCodec() StreamCodec
NewStreamCodec returns an ASCII85 stream serializer.
Example ¶
package main
import (
"bytes"
"fmt"
"github.com/foomo/goencode/ascii85"
)
func main() {
c := ascii85.NewStreamCodec()
var buf bytes.Buffer
if err := c.Encode(&buf, []byte("hello")); err != nil {
fmt.Printf("Encode failed: %v\n", err)
return
}
fmt.Printf("Encoded: %s\n", buf.String())
var decoded []byte
if err := c.Decode(bytes.NewReader(buf.Bytes()), &decoded); err != nil {
fmt.Printf("Decode failed: %v\n", err)
return
}
fmt.Printf("Decoded: %s\n", string(decoded))
}
Output: Encoded: BOu!rDZ Decoded: hello
Click to show internal directories.
Click to hide internal directories.