ident: member interface

For representing full identifiers of system and member.

Signed-off-by: Yonah <contrib@gensokyo.uk>
This commit is contained in:
2026-03-22 16:34:51 +09:00
parent c0c39f34f0
commit 1354a2c9a3
4 changed files with 31 additions and 1 deletions

View File

@@ -3,7 +3,9 @@
package ident
import (
"encoding"
"errors"
"fmt"
"strconv"
)
@@ -21,3 +23,21 @@ func (e *UnexpectedSizeError) Error() string {
return "got " + strconv.Itoa(len(e.Data)) + " bytes for " +
"a " + strconv.Itoa(e.Want) + "-byte identifier"
}
// MS is a system or member identifier.
type MS interface {
encoding.TextMarshaler
encoding.TextUnmarshaler
fmt.Stringer
// EncodedSize returns the number of bytes appended by Encode.
EncodedSize() int
// Encode appends the canonical string representation of MS to dst and
// returns the extended buffer.
Encode(dst []byte) []byte
// ident is a no-op function but serves to distinguish types that are
// identifiers from ordinary types with custom marshaler/unmarshaler
// behaviour: a type is an identifier part if it has an ident method.
ident()
}