Documentation
¶
Overview ¶
Package serializer 序列化相关的接口定义
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnsupported = localeutil.Error("unsupported serialization")
ErrUnsupported 返回不支持序列化的错误信息
当一个对象无法被正常的序列化或是反序列化时返回此错误。
Functions ¶
This section is empty.
Types ¶
type FS ¶
type FS interface {
// Serializer 序列化函数管理接口
Serializer() Serializer
// Save 将 v 序列化并保存至 p
//
// 根据 p 后缀名选择序列化方法。
Save(p string, v any) error
// Load 加载文件到 v
//
// 根据 name 后缀名选择序列化方法。
Load(fsys fs.FS, name string, v any) error
}
FS 对文件系统的序列化支持
type Serializer ¶
type Serializer interface {
// Items 返回所有的注册项名称
Items() []string
// Exists 是否指定名称的项
Exists(string) bool
// Add 添加序列化函数
//
// m 和 u 可以为 nil,表示仅作为一个占位符使用;
//
// name 表示之后用于查找该序列化函数的唯一 ID,
// 后期用户可以根据 name 从 Search 直接查找相应的序列化函数。
Add(m MarshalFunc, u UnmarshalFunc, name ...string) error
// Set 修改或是添加
Set(name string, m MarshalFunc, u UnmarshalFunc)
// Delete 删除指定名称的序列化方函数
Delete(name string)
// Search 根据注册时的名称查找
Search(name string) (string, MarshalFunc, UnmarshalFunc)
// SearchFunc 按指定方法查找序列化方法
//
// 如果返回的 name 为空,表示没有找到
SearchFunc(match func(string) bool) (string, MarshalFunc, UnmarshalFunc)
// Len 返回注册的数量
Len() int
}
Serializer 管理注册的序列化函数
Directories
¶
| Path | Synopsis |
|---|---|
|
Package form 用于处理 www-form-urlencoded 编码
|
Package form 用于处理 www-form-urlencoded 编码 |
|
Package html 提供输出 HTML 内容的解码函数
|
Package html 提供输出 HTML 内容的解码函数 |
|
Package jsonp JSONP 序列化操作
|
Package jsonp JSONP 序列化操作 |
|
Package text 针对文本内容的编解码实现
|
Package text 针对文本内容的编解码实现 |
|
testobject
Package testobject 用于 text 测试对象
|
Package testobject 用于 text 测试对象 |
Click to show internal directories.
Click to hide internal directories.