package pop3 import ( "bytes" "io" ) // Framed represents a byte stream framed according to POP3 semantics. // Framed is expected to be called synchronously. type Framed struct { // TODO remove? Strict bool transport io.ReadWriteCloser // Not using a pointer is a crude micro-optimisation which works since this // buffer is only ever accessed through a *Framed pointer. inbuf bytes.Buffer } func Frame(transport io.ReadWriteCloser) *Framed { return &Framed{ transport: transport, inbuf: *bytes.NewBuffer(make([]byte, 0, MaximumPhysicalLineLength)), } } // NOTE: (*Framed).Close does NOT send a QUIT command. func (framed *Framed) Close() error { framed.inbuf.Reset() return framed.transport.Close() }