Something went wrong. Try again.
Classic Unix mailbox files for Zig 0.16: an iterator to read, a predicate to delete, an atomic rewrite for every change.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
//! Classic Unix mailboxes: reading the messages out of one, adding messages to//! it, and removing the ones you do not want.//!//! # What an mbox is//!//! Messages one after another in a file, and nothing else. No index, no length//! field, no checksum, no version. The only mark of where a message starts is//! a line beginning `From ` — the *postmark*, which is not RFC 5322 and is not//! specified anywhere — and a message ends at the line before the next one.//!//! Everything difficult about the format follows from that. A body containing//! a line that begins `From ` is a body that can split its own message in two,//! so every mbox does something about it, and what it does is the `Variant`.//! The four are not compatible, nothing in the file says which one it is, and//! guessing wrong corrupts every body it touches — which is why it is a//! parameter here and never a detection.//!//! # Three layers, and you can stop at any of them//!//! `From` and `variant` are pure functions over bytes: the postmark, and the//! quoting that keeps a body from being mistaken for one. No I/O, no//! allocation.//!//! `Reader`, `Writer` and `filter` work over any `std.Io.Reader` and//! `std.Io.Writer`, which is where the whole of the difficult part lives —//! deciding where one message stops and the next starts — so that it can be//! used, tested and fuzzed with no filesystem anywhere near it.//!//! `Mailbox` is the file: the locking, and the atomic rewrite that any change//! to an mbox needs. Read its doc comment before pointing it at a live spool;//! there is a thing it deliberately cannot do.//!//! # What is not here//!//! Reading the messages. An mbox is a way of putting many messages in one//! file, and what is inside them is//! [zig-mime](https://git.jcollie.dev/jeff/zig-mime)'s subject.//! `Reader.Entry.parse` hands the bytes straight over and is the whole of the//! connection between the two.
/// The postmark: the `From ` line in front of every message.pub const From = @import("From.zig");/// Which mbox this is, and the quoting that follows from it.pub const variant = @import("variant.zig");/// The four incompatible ways a mailbox keeps a body from splitting itself.pub const Variant = variant.Variant;/// Reading a mailbox: an iterator over the messages in one.pub const Reader = @import("Reader.zig");/// Writing a mailbox: putting messages onto a stream, one after another.pub const Writer = @import("Writer.zig");/// Removing messages, which in this format means writing the mailbox again/// without them.pub const filter = @import("filter.zig");/// A mailbox file: the locking, and the atomic rewrite that a change needs.pub const Mailbox = @import("Mailbox.zig");
test { _ = From; _ = variant; _ = Reader; _ = Writer; _ = filter; _ = Mailbox;}