XU XUv0.8.8
中文

API

#encoding/pem

import: #encoding/pem

counts: 2 fns, 1 methods, 1 types, 0 consts, 0 ifaces

PEM decode / encode_to_memory.

struct Block

XuAPI
pub struct Block {
    pub typ string
    pub keys []string
    pub vals []string
    pub bytes string
    pub rest string
}

Purpose

PEM (RFC 1421) aligned with `encoding/pem` Decode / EncodeToMemory. No map: optional headers are parallel keys/vals. decode returns a Block with empty typ when no PEM is found ( returns nil, rest=original). Subset: first BEGIN at start-of-line through matching END; no nested scan.

Parameters

typ string
field (string)
keys []string
field ([]string)
vals []string
field ([]string)
bytes string
field (string)
rest string
field (string)

decode

XuAPI
pub fn decode(data &string) Block

Purpose

Decode.

Parameters

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

Returns

Block — a value of this type

(Block) header

XuAPI
pub fn (b Block) header(key string) string

Purpose

Call `header` on `Block`.

Parameters

b Block
receiver Block (value receiver)
key string
key (string)

Returns

string — result string

encode_to_memory

XuAPI
pub fn encode_to_memory(b &Block) string

Purpose

Encode.

Parameters

b &Block
b (borrowed; caller keeps it; type &Block)

Returns

string — result string