~nikwen/account-polld/imap-new

« back to all changes in this revision

Viewing changes to plugins/imap/text/encoding/ianaindex/ianaindex.go

  • Committer: Niklas Wenzel
  • Date: 2016-02-28 22:50:08 UTC
  • Revision ID: nikwen.developer@gmail.com-20160228225008-wqee6wahnre61qla
Initial commit for the cleaned up IMAP plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2015 The Go Authors. All rights reserved.
 
2
// Use of this source code is governed by a BSD-style
 
3
// license that can be found in the LICENSE file.
 
4
 
 
5
// Package ianaindex maps names to Encodings as specified by the IANA registry.
 
6
// This includes both the MIME and IANA names.
 
7
//
 
8
// See http://www.iana.org/assignments/character-sets/character-sets.xhtml for
 
9
// more details.
 
10
package ianaindex
 
11
 
 
12
import (
 
13
        "launchpad.net/account-polld/plugins/imap/text/encoding"
 
14
)
 
15
 
 
16
// TODO: allow users to specify their own aliases?
 
17
// TODO: allow users to specify their own indexes?
 
18
// TODO: allow canonicalizing names
 
19
 
 
20
// NOTE: only use these top-level variables if we can get the linker to drop
 
21
// the indexes when they are not used. Make them a function or perhaps only
 
22
// support MIME otherwise.
 
23
 
 
24
var (
 
25
        // MIME is an index to map MIME names. It does not support aliases.
 
26
        MIME *Index
 
27
 
 
28
        // IANA is an index that supports all names and aliases using IANA names as
 
29
        // the canonical identifier.
 
30
        IANA *Index
 
31
)
 
32
 
 
33
// Index maps names registered by IANA to Encodings.
 
34
type Index struct {
 
35
}
 
36
 
 
37
// Get returns an Encoding for IANA-registered names. Matching is
 
38
// case-insensitive.
 
39
func (x *Index) Get(name string) (encoding.Encoding, error) {
 
40
        panic("TODO: implement")
 
41
}
 
42
 
 
43
// Name reports the canonical name of the given Encoding. It will return an
 
44
// error if the e is not associated with a known encoding scheme.
 
45
func (x *Index) Name(e encoding.Encoding) (string, error) {
 
46
        panic("TODO: implement")
 
47
}
 
48
 
 
49
// TODO: the coverage of this index is rather spotty. Allowing users to set
 
50
// encodings would allow:
 
51
// - users to increase coverage
 
52
// - allow a partially loaded set of encodings in case the user doesn't need to
 
53
//   them all.
 
54
// - write an OS-specific wrapper for supported encodings and set them.
 
55
// The exact definition of Set depends a bit on if and how we want to let users
 
56
// write their own Encoding implementations. Also, it is not possible yet to
 
57
// only partially load the encodings without doing some refactoring. Until this
 
58
// is solved, we might as well not support Set.
 
59
// // Set sets the e to be used for the encoding scheme identified by name. Only
 
60
// // canonical names may be used. An empty name assigns e to its internally
 
61
// // associated encoding scheme.
 
62
// func (x *Index) Set(name string, e encoding.Encoding) error {
 
63
//      panic("TODO: implement")
 
64
// }