src/lib/message

  Source   Edit

A class that represents an individual Maildir, and a Message class to nanage files underneath them.

Types

Maildir = ref object
  path*: string              ## Absolute path to the encapsuating dir
  cur: string
  new: string
  tmp: string
  Source   Edit
Message = ref object
  basename: string
  dir: Maildir
  headers*: Table[string, seq[string]]
  path: string
  stream: FileStream
  Source   Edit

Procs

proc delete(msg: Message) {....raises: [Exception, IOError, OSError, ValueError],
                            tags: [WriteIOEffect, WriteDirEffect].}
Remove a message from disk.   Source   Edit
proc evalRules(msg: var Message; rules: seq[Rule]; default: Maildir): bool {....raises: [
    IOError, OSError, KeyError, RegexError, ValueError, IOError, ValueError,
    Exception], tags: [ReadIOEffect, WriteIOEffect, ExecIOEffect, ReadEnvEffect,
                       RootEffect, TimeEffect, ReadDirEffect, WriteDirEffect].}
Evaluate each rule against the Message, returning true if there was a valid match found.   Source   Edit
proc filter(orig_msg: Message; cmd: seq[string]): Message {.
    ...raises: [IOError, Exception, ValueError], tags: [ExecIOEffect,
    ReadEnvEffect, RootEffect, WriteIOEffect, ReadIOEffect, TimeEffect,
    ReadDirEffect, WriteDirEffect].}
Filter message content through an external program, returning a new Message if successful.   Source   Edit
proc newMaildir(path: string): Maildir {.
    ...raises: [ValueError, IOError, ValueError],
    tags: [ReadDirEffect, WriteIOEffect, WriteDirEffect].}
Create and return a new Maildir object, making it on-disk if necessary.   Source   Edit
proc newMessage(dir: Maildir): Message {....raises: [ValueError],
    tags: [TimeEffect, WriteIOEffect, ReadDirEffect, WriteDirEffect].}
Create and return a Message - an open FileStream under a specific Maildir (in tmp)   Source   Edit
proc open(msg: Message) {....raises: [IOError], tags: [].}
Open (or re-open) a Message file stream for reading.   Source   Edit
proc parseHeaders(msg: Message) {....raises: [IOError, OSError, KeyError,
    RegexError, ValueError], tags: [ReadIOEffect, WriteIOEffect].}
Walk the RFC2822 headers, placing them into memory. This 'unwraps' multiline headers, and allows for duplicate headers.   Source   Edit
proc save(msg: Message; dir = msg.dir) {.
    ...raises: [Exception, IOError, OSError, ValueError],
    tags: [WriteIOEffect, ReadDirEffect, ReadIOEffect].}
Move the message from tmp to new. Defaults to its current maildir, but can be provided a different one.   Source   Edit
proc subDir(dir: Maildir; path: string): Maildir {.
    ...raises: [ValueError, IOError],
    tags: [ReadDirEffect, WriteIOEffect, WriteDirEffect].}
Creates a new Maildir relative to an existing one.   Source   Edit
proc writeStdin(msg: Message): Message {.
    ...raises: [IOError, OSError, Exception, ValueError],
    tags: [ReadIOEffect, WriteIOEffect].}
Streams stdin to the message file, returning the Message object for chaining.   Source   Edit