metadata

package
Version: v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(suffix *regexp.Regexp, factory Factory)

Register registers new Factory with corresponding suffix regexp.

Types

type Factory

type Factory interface {
	Create(suffix string) Metadata
}

Factory creates Metadata objects given suffix.

type LastAccessTime

type LastAccessTime struct {
	Time time.Time
}

LastAccessTime tracks a file's last access time.

func NewLastAccessTime

func NewLastAccessTime(t time.Time) *LastAccessTime

NewLastAccessTime creates a LastAccessTime from t.

func (*LastAccessTime) Deserialize

func (t *LastAccessTime) Deserialize(b []byte) error

Deserialize loads b into t.

func (*LastAccessTime) GetSuffix

func (t *LastAccessTime) GetSuffix() string

GetSuffix returns the metadata suffix.

func (*LastAccessTime) Movable

func (t *LastAccessTime) Movable() bool

Movable is true.

func (*LastAccessTime) Serialize

func (t *LastAccessTime) Serialize() ([]byte, error)

Serialize converts t to bytes.

type Metadata

type Metadata interface {
	GetSuffix() string
	Movable() bool
	Serialize() ([]byte, error)
	Deserialize([]byte) error
}

Metadata defines types of matadata file. All implementations of Metadata must register themselves.

func CreateFromSuffix

func CreateFromSuffix(suffix string) Metadata

CreateFromSuffix creates a Metadata obj based on suffix. This is not a very efficient method; It's mostly used during reload.

type Persist

type Persist struct {
	Value bool
}

Persist marks whether a blob should be persisted.

func NewPersist

func NewPersist(v bool) *Persist

NewPersist creates a new Persist, where true means the blob should be persisted, and false means the blob is safe to delete.

func (*Persist) Deserialize

func (m *Persist) Deserialize(b []byte) error

Deserialize loads b into m.

func (*Persist) GetSuffix

func (m *Persist) GetSuffix() string

GetSuffix returns a static suffix.

func (*Persist) Movable

func (m *Persist) Movable() bool

Movable is true.

func (*Persist) Serialize

func (m *Persist) Serialize() ([]byte, error)

Serialize converts m to bytes.

type TorrentMeta

type TorrentMeta struct {
	MetaInfo *core.MetaInfo
}

TorrentMeta wraps torrent metainfo storage as metadata.

func NewTorrentMeta

func NewTorrentMeta(mi *core.MetaInfo) *TorrentMeta

NewTorrentMeta return a new TorrentMeta.

func (*TorrentMeta) Deserialize

func (m *TorrentMeta) Deserialize(b []byte) error

Deserialize loads b into m.

func (*TorrentMeta) GetSuffix

func (m *TorrentMeta) GetSuffix() string

GetSuffix returns a static suffix.

func (*TorrentMeta) Movable

func (m *TorrentMeta) Movable() bool

Movable is true.

func (*TorrentMeta) Serialize

func (m *TorrentMeta) Serialize() ([]byte, error)

Serialize converts m to bytes.

Jump to

Keyboard shortcuts

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