serialization

package
v0.59.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package serialization 序列化相关的功能实现

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c int) serializer.Serializer

Types

type FS

type FS struct {
	// contains filtered or unexported fields
}

func NewFS

func NewFS(cap int) *FS

func (*FS) Load

func (f *FS) Load(fsys fs.FS, name string, v any) error

func (*FS) Save

func (f *FS) Save(p string, v any) error

func (*FS) SearchByExt

func (f *FS) SearchByExt(filename string) (serializer.MarshalFunc, serializer.UnmarshalFunc)

func (*FS) Serializer

func (f *FS) Serializer() serializer.Serializer

type Item

type Item struct {
	Name      string
	Marshal   serializer.MarshalFunc
	Unmarshal serializer.UnmarshalFunc
}

type Mimetypes

type Mimetypes struct {
	serializer.Serializer
}

func NewMimetypes

func NewMimetypes(c int) *Mimetypes

func (*Mimetypes) ContentType

ContentType 从 content-type 报头中获取解码和字符集函数

h 表示 content-type 报头的内容。如果字符集为 utf-8 或是未指定,返回的字符解码为 nil;

func (*Mimetypes) MarshalFunc

func (ms *Mimetypes) MarshalFunc(h string) (string, serializer.MarshalFunc, bool)

MarshalFunc 从 h 解析出当前请求所需要的 mimetype 名称和对应的解码函数

*/* 或是空值 表示匹配任意内容,一般会选择第一个元素作匹配; xx/* 表示匹配以 xx/ 开头的任意元素,一般会选择 xx/* 开头的第一个元素; xx/ 表示完全匹配以 xx/ 的内容 如果传递的内容如下:

application/json;q=0.9,*/*;q=1

则因为 */* 的 q 值比较高,而返回 */* 匹配的内容

在不完全匹配的情况下,返回值的名称依然是具体名称。

text/*;q=0.9

返回的名称可能是:

text/plain

type Serialization

type Serialization struct {
	// contains filtered or unexported fields
}

func (*Serialization) Add

func (*Serialization) Delete

func (s *Serialization) Delete(name string)

func (*Serialization) Exists added in v0.59.1

func (s *Serialization) Exists(name string) bool

func (*Serialization) Items added in v0.59.1

func (s *Serialization) Items() []string

func (*Serialization) Len

func (s *Serialization) Len() int

func (*Serialization) Search

func (*Serialization) SearchFunc

func (*Serialization) Set

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL