The traffic log: a direction tagged, CRLF terminated line sink.
This is the MoonBit equivalent of upstream debug.go's TeeReader /MultiWriter pair, assembled into one object because a single transcript isthe point -- two untagged writers produce exactly the log you cannot debugwith. Upstream derives the direction implicitly, by teeing the socket's readside and fanning out its write side; here the direction is an explicit tag,so the record stays self describing even if a caller routes the twodirections into different sinks.
The two directions get one record path each, write_path and read_path;Control routes both of its directions through them, so the transcript andthe protocol see the same bytes. They are functions rather than theMultiWriter / TeeReader decorators upstream uses because a decoratorneeds impl @io.Writer for <new type>, and MoonBit lets only the definingpackage write that -- a decorator living here could never wrap the socketControl holds.
Read one line through the log: inner.read_until frames it, the bytes thatwere actually produced are recorded before the framed line is returned.
This used to be the TeeLogReader decorator, moved to a function for thesame ownership reason as write_path. It records what it read includingfalse reads -- a zero length read is not an error, there was simply no line.
Record one already CRLF terminated record, byte for byte.
This is the entry point the control channel uses: it hands over exactly thebytes it is about to write (or has just read), so the transcript cannotdisagree with the wire even when the payload is not valid UTF-8. A sinkthat raises loses the record, never the caller -- see write_path andread_path below.
One write through the log: the bytes go to inner first, then the bytesthat inner actually accepted are recorded.
The order is the point. A write that raises still records what wasattempted (the command never reached the wire, and that is the single mostuseful line in a desynchronised session), but a short write records onlywhat the socket took -- logging the offered buffer would put bytes in thetranscript that never left the client.
This used to be the MirrorWriter decorator. It is a function now becausethe type lived in this package while Control did not, and MoonBit doesnot let another package impl @io.Writer for a type it does not own.
FTP/FTPS client library for MoonBit with passive EPSV/PASV data connections, MLSD/LIST parsing, resume, directory tree walking, and explicit/implicit TLS.