Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode produces the raw yEnc article body for one part of a file — the exact inverse of Decode. It is the encoder the download path never needed but the tests do: it lets fixtures build deterministic articles that round-trip through Decode (CRC32 verified) with no real Usenet server.
- name filename advertised in =ybegin (must be last on that line).
- partNum 1-based part number; total the number of parts in the file.
- begin/end 1-based byte offsets of this part within the file (=ypart), inclusive on both ends, so len(data) == end-begin+1.
- fileSize total size of the whole file (=ybegin size=).
- data the raw bytes of THIS part.
When total <= 1 a single-part body (no =ypart, crc32= in =yend) is emitted; otherwise a multipart body (=ypart + pcrc32= in =yend) matching what the streaming OffsetIndex relies on.
Types ¶
type Part ¶
type Part struct {
Name string // filename from =ybegin
Number int // part number (1-based)
Total int // total parts (from =ybegin total=N)
Begin int64 // byte offset start (from =ypart begin=N, 1-based)
End int64 // byte offset end (from =ypart end=N, inclusive)
Size int64 // total file size (from =ybegin size=N)
CRC32 uint32 // CRC32 of this part's data (from =yend pcrc32)
Data []byte // decoded binary data
}
Part represents a decoded yEnc part (one NNTP article body).
func Decode ¶
Decode reads a yEnc encoded article body and returns the decoded part. The reader should contain the raw article body (after NNTP BODY response).
func DecodeBytes ¶
DecodeBytes decodes a yEnc encoded byte slice.