Documentation ¶
Overview ¶
Package conversion is for the process of taking an input format and running it through various converters to arrive at an output format
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ConversionProgressCtxKey ctxKey = "ConversionProgress"
Functions ¶
func Convert ¶
func Convert( ctx context.Context, conversionPath []MsgConverter, msgInputPath string, msgOutputPath string, attachmentIn attachments.Store, attachmentOut attachments.Store, msgFileFlags int, msgFilePermissions fs.FileMode, ) error
Convert between MsgFormats and AttachmentFormats. Does not handle opening/closing input/output files, but will handle opening/closing any temporary files needed. If you want to get updates on the progress of the conversion, pass a chan *MsgConverter via the context key ConversionProgressCtxKey - it should be buffered, and of length len(conversionPath). If you don't know what to do for the last 2 parameters, I'd suggest using os.O_TRUNC|os.O_CREATE|os.O_WRONLY, 0600
Types ¶
type Conversion ¶
type Conversion struct { // ExternalAttachments should only be used by a MsgConverter which has a MsgFormat that has IncludesAttachments set to false. // If both the input and output formats include attachments within them, then this should be nil. // This is also made read-only or write-only if only one of the formats have attachments. ExternalAttachments attachments.Store MsgIn interface{} MsgOut interface{} MsgFileFlags int MsgFilePermissions os.FileMode // contains filtered or unexported fields }
func (*Conversion) AddCleanUpFn ¶
func (c *Conversion) AddCleanUpFn(fn func(conversionSuccessful bool) error)
AddCleanUpFn will schedule a function to run after the conversion is done (whether it's successful or not)
func (*Conversion) AddFinalCleanUpFn ¶
func (c *Conversion) AddFinalCleanUpFn(fn func(conversionSuccessful bool) error)
AddFinalCleanUpFn adds a function that will run after the last conversion finishes, or if there was an error during the conversion. If there's an error during a step of the conversion, your function will still be run.
func (*Conversion) CurrentConverter ¶
func (c *Conversion) CurrentConverter() *MsgConverter
CurrentConverter returns the MsgConverter that will be used next time Convert is called, or nil if no converter will be used because the Conversion is finished
func (*Conversion) Finished ¶
func (c *Conversion) Finished() bool
Finished says whether or not the Conversion has successfully finished (because it has gone through all the MsgConverters needed for this Conversion)
func (*Conversion) IsFinalConversion ¶
func (c *Conversion) IsFinalConversion() bool
IsFinalConversion lets you know if this is the last conversion between formats in the entire conversion path
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
type MsgConverter ¶
type MsgConverter struct { InputFormat formats.MsgFormat OutputFormat formats.MsgFormat // Convert between the formats, respecting if the context is canceled // Note: if your input format isn't intermediate, then input format should be a file path string. If your output format isn't intermediate, then you should save your output to the output path provided Convert func(ctx context.Context, c *Conversion) (intermediateOutput interface{}, err error) }