XU XUv0.8.8
中文

API

#encoding/asn1

import: #encoding/asn1

counts: 11 fns, 9 methods, 2 types, 15 consts, 0 ifaces

DER TLV; INTEGER fits in i64.

const class_universal

XuAPI
pub const class_universal = 0

Purpose

DER subset aligned with `encoding/asn1` Marshal/Unmarshal of primitive values. No reflect: a Value is one TLV (tag + content) SEQUENCE is walked with Decoder.next. INTEGER fits i64. as_octet / as_utf8 / as_null / as_bit_string match the marshal_* tags. Value `0`.

Parameters

none

const class_context

XuAPI
pub const class_context = 2

Purpose

Public constant `class_context`. Value `2`.

Parameters

none

const tag_boolean

XuAPI
pub const tag_boolean = 1

Purpose

Public constant `tag_boolean`. Value `1`.

Parameters

none

const tag_integer

XuAPI
pub const tag_integer = 2

Purpose

Public constant `tag_integer`. Value `2`.

Parameters

none

const tag_bit_string

XuAPI
pub const tag_bit_string = 3

Purpose

Public constant `tag_bit_string`. Value `3`.

Parameters

none

const tag_octet_string

XuAPI
pub const tag_octet_string = 4

Purpose

Public constant `tag_octet_string`. Value `4`.

Parameters

none

const tag_null

XuAPI
pub const tag_null = 5

Purpose

Public constant `tag_null`. Value `5`.

Parameters

none

const tag_oid

XuAPI
pub const tag_oid = 6

Purpose

Public constant `tag_oid`. Value `6`.

Parameters

none

const tag_utf8_string

XuAPI
pub const tag_utf8_string = 12

Purpose

Public constant `tag_utf8_string`. Value `12`.

Parameters

none

const tag_sequence

XuAPI
pub const tag_sequence = 16

Purpose

Public constant `tag_sequence`. Value `16`.

Parameters

none

const tag_set

XuAPI
pub const tag_set = 17

Purpose

Public constant `tag_set`. Value `17`.

Parameters

none

const tag_printable_string

XuAPI
pub const tag_printable_string = 19

Purpose

Public constant `tag_printable_string`. Value `19`.

Parameters

none

const tag_ia5_string

XuAPI
pub const tag_ia5_string = 22

Purpose

Public constant `tag_ia5_string`. Value `22`.

Parameters

none

const tag_utc_time

XuAPI
pub const tag_utc_time = 23

Purpose

Public constant `tag_utc_time`. Value `23`.

Parameters

none

const tag_generalized_time

XuAPI
pub const tag_generalized_time = 24

Purpose

Public constant `tag_generalized_time`. Value `24`.

Parameters

none

struct Value

XuAPI
pub struct Value {
    pub class int
    pub constructed int
    pub tag int
    pub bytes string
    pub rest string
}

Purpose

Public struct `Value`.

Parameters

class int
field (int)
constructed int
field (int)
tag int
field (int)
bytes string
field (string)
rest string
field (string)

struct Decoder

XuAPI
pub struct Decoder {
    pub data string
    pub pos int
}

Purpose

Public struct `Decoder`.

Parameters

data string
data
pos int
field (int)

new_decoder

XuAPI
pub fn new_decoder(data &string) Decoder

Purpose

Construct decoder.

Parameters

data &string
data (borrowed; caller keeps it; type &string)

Returns

Decoder — a value of this type

marshal_bool

XuAPI
pub fn marshal_bool(v bool) string

Purpose

Marshal bool.

Parameters

v bool
value (bool)

Returns

string — result string

marshal_null

XuAPI
pub fn marshal_null() string

Purpose

Marshal null.

Parameters

none

Returns

string — result string

marshal_octet

XuAPI
pub fn marshal_octet(s &string) string

Purpose

Marshal octet.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

marshal_utf8

XuAPI
pub fn marshal_utf8(s &string) string

Purpose

Marshal utf8.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

marshal_bit_string

XuAPI
pub fn marshal_bit_string(s &string) string

Purpose

Marshal bit string.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

string — result string

marshal_int

XuAPI
pub fn marshal_int(n int) string

Purpose

Marshal int.

Parameters

n int
count, length, or limit (int)

Returns

string — result string

marshal_oid

XuAPI
pub fn marshal_oid(arcs &[]int) string

Purpose

Marshal oid. Throws on failure.

Parameters

arcs &[]int
arcs (borrowed; caller keeps it; type &[]int)

Returns

string — result string

marshal_seq

XuAPI
pub fn marshal_seq(elems &[]string) string

Purpose

Marshal seq.

Parameters

elems &[]string
elems (borrowed; caller keeps it; type &[]string)

Returns

string — result string

unmarshal

XuAPI
pub fn unmarshal(data &string) Value

Purpose

unmarshal; returns Value. Throws on failure.

Parameters

data &string
data (borrowed; caller keeps it; type &string)

Returns

Value — a value of this type

parse_at

XuAPI
pub fn parse_at(data &string, off int) Value

Purpose

Parse as at. Throws on failure.

Parameters

data &string
data (borrowed; caller keeps it; type &string)
off int
offset (int)

Returns

Value — a value of this type

(Decoder) done

XuAPI
pub fn (d Decoder) done() bool

Purpose

Call `done` on `Decoder`.

Parameters

d Decoder
receiver Decoder (value receiver)

Returns

bool — true or false

(Value) as_bit_string

XuAPI
pub fn (v Value) as_bit_string() string

Purpose

Method on `Value`: as bit string. Throws on failure.

Parameters

v Value
receiver Value (value receiver)

Returns

string — result string

(&mut Decoder) next

XuAPI
pub fn (d &mut Decoder) next() Value

Purpose

Method on `&mut Decoder`: take the next item, or end according to this type. Throws on failure.

Parameters

d &mut Decoder
receiver &mut Decoder (exclusive borrow)

Returns

Value — a value of this type

(Value) as_bool

XuAPI
pub fn (v Value) as_bool() bool

Purpose

Method on `Value`: as bool. Throws on failure.

Parameters

v Value
receiver Value (value receiver)

Returns

bool — true or false

(Value) as_int

XuAPI
pub fn (v Value) as_int() int

Purpose

Method on `Value`: as int. Throws on failure.

Parameters

v Value
receiver Value (value receiver)

Returns

int — a value of this type

(Value) as_octet

XuAPI
pub fn (v Value) as_octet() string

Purpose

Method on `Value`: as octet. Throws on failure.

Parameters

v Value
receiver Value (value receiver)

Returns

string — result string

(Value) as_utf8

XuAPI
pub fn (v Value) as_utf8() string

Purpose

Method on `Value`: as utf8. Throws on failure.

Parameters

v Value
receiver Value (value receiver)

Returns

string — result string

(Value) as_null

XuAPI
pub fn (v Value) as_null() bool

Purpose

Method on `Value`: as null. Throws on failure.

Parameters

v Value
receiver Value (value receiver)

Returns

bool — true or false

(Value) as_oid

XuAPI
pub fn (v Value) as_oid() []int

Purpose

Method on `Value`: as oid. Throws on failure.

Parameters

v Value
receiver Value (value receiver)

Returns

[]int — slice result