Crate yenc[][src]

yEnc is an encoding scheme to include binary files in Usenet messages.

The EncodeOptions and DecodeOptions structs are the entry points for encoding and decoding.

To encode a complete file to a single encoded

let encode_options = yenc::EncodeOptions::new();
let mut output_file = std::fs::File::create("test.bin.001").unwrap();
encode_options.encode_file("test1.bin", &mut output_file).unwrap();

To decode from a stream and place the targets files in the output directory

let tmpdir = "tmp";
std::fs::create_dir(tmpdir).unwrap();
let decode_options = yenc::DecodeOptions::new(tmpdir);
let message = Vec::<u8>::new();
// ...
// obtain message from a socket, for example the body of a usenet article.
// alternatively, directly read from the NNTP TCPStream.
// ...
decode_options.decode_stream(message.as_slice()).unwrap();

Structs

DecodeOptions

Options for decoding. The entry point for decoding from a file or (TCP) stream to an output directory.

EncodeOptions

Options for encoding. The entry point for encoding a file (part) to a file or (TCP) stream.

Enums

DecodeError

Error enum for errors that can be encountered while decoding.

EncodeError

Error enum for errors that can be encountered when validating the encode options or while encoding.

Functions

decode_buffer

Decode the encoded byte slice into a vector of bytes.

encode_buffer

Encodes the input buffer and writes it to the writer.