pub struct Connection { /* private fields */ }Implementations§
Source§impl Connection
impl Connection
pub fn new(config: Config) -> Result<Self, Error>
pub fn state(&self) -> State
pub fn capabilities(&self) -> &Capabilities
pub fn output(&self) -> &[u8] ⓘ
pub fn consume_output(&mut self, count: usize)
pub fn poll_event(&mut self) -> Option<Event>
pub fn connected(&mut self, now: Instant) -> Result<(), Error>
pub fn tls_established(&mut self, now: Instant) -> Result<(), Error>
pub fn receive(&mut self, bytes: &[u8], now: Instant) -> Result<(), Error>
Sourcepub fn send(
&mut self,
token: u64,
envelope: Envelope,
message_id: String,
content: &[u8],
now: Instant,
) -> Result<(), Error>
pub fn send( &mut self, token: u64, envelope: Envelope, message_id: String, content: &[u8], now: Instant, ) -> Result<(), Error>
Move the result’s inherent envelope/ID ownership into the core. content
may be lettre’s formatted MIME bytes or another already-built message.
For a message too large to hold twice in memory, use Self::start_send.
Sourcepub fn start_send(
&mut self,
token: u64,
envelope: Envelope,
message_id: String,
body: StreamBody,
now: Instant,
) -> Result<(), Error>
pub fn start_send( &mut self, token: u64, envelope: Envelope, message_id: String, body: StreamBody, now: Instant, ) -> Result<(), Error>
Starts a message whose content is streamed instead of passed whole.
MAIL/RCPT/DATA proceed as for Self::send; once the server accepts
DATA the core emits Event::BodyReady, after which the host passes the
content in any number of Self::send_chunk calls and then calls
Self::finish_body. Line-ending normalization and dot-stuffing carry
across chunk boundaries, so any split yields the bytes send would.
The result is the same single Sent/Failed for token.
Sourcepub fn can_send_body(&self) -> bool
pub fn can_send_body(&self) -> bool
True between Event::BodyReady and Self::finish_body.
Sourcepub fn send_chunk(&mut self, chunk: &[u8], now: Instant) -> Result<(), Error>
pub fn send_chunk(&mut self, chunk: &[u8], now: Instant) -> Result<(), Error>
Encodes one piece of a streamed message into output(). Drain output()
between chunks to keep memory bounded by the chunk size. 8-bit bytes in
a body not declared eight_bit cannot be retracted mid-DATA, so they
fail the transaction and close the transport.
Sourcepub fn finish_body(&mut self, now: Instant) -> Result<(), Error>
pub fn finish_body(&mut self, now: Instant) -> Result<(), Error>
Ends a streamed message: terminates its last line if needed and writes
the . terminator. The server’s reply settles the token.