/
types.go
66 lines (48 loc) · 2.45 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package content
//import "gopkg.in/webnice/debug.v1"
//import "gopkg.in/webnice/log.v2"
import (
"io"
"gopkg.in/webnice/transport.v2/data"
"golang.org/x/text/encoding"
)
// Interface is an interface of package
type Interface interface {
io.WriterTo
// Transcode is an transcoding content from the specified encoding to UTF-8
Transcode(e encoding.Encoding) Interface
// Transform is an transforming content using a custom function
Transform(fn TransformFunc) Interface
// String Return content as string
String() (string, error)
// Bytes Return content as []byte
Bytes() ([]byte, error)
// UnmarshalJSON Decoding content like JSON
UnmarshalJSON(o interface{}) error
// UnmarshalXML Decoding content like XML
UnmarshalXML(o interface{}) error
// UnTar Разархивация контента методом TAR
UnTar() Interface
// UnZip Разархивация контента методом ZIP (извлекается только первый файл)
UnZip() Interface
// UnGzip Разархивация контента методом GZIP
UnGzip() Interface
// UnFlate Разархивация контента методом FLATE
UnFlate() Interface
// BackToBegin Returns the content reading pointer to the beginning
// This allows you to repeat the work with content
BackToBegin() error
}
// TransformFunc is an func for streaming content conversion
type TransformFunc func(r io.Reader) (io.Reader, error)
// impl is an implementation of package
type impl struct {
esence data.ReadAtSeekerWriteToCloser // Данные контента
rdc io.ReadCloser // Интерфейс
transcode encoding.Encoding // Если не равно nil, то контент перекодируется на лету из указанной кодировки
transform TransformFunc // Функция потокового преобразования контента
unzip bool // =true - контент разархивируется алгоритмом сжатия ZIP, возвращается первый файл в архиве
untar bool // =true - контент разархивируется алгоритмом сжатия TAR
ungzip bool // =true - контент разархивируется алгоритмом сжатия GZIP
unflate bool // =true - контент разархивируется алгоритмом сжатия FLATE
}