feat: Add encoderhero and heroscript_dumps/loads
- Add encoderhero import to multiple modules - Implement heroscript_dumps and heroscript_loads functions - Update several methods to use `if mut` for cleaner optionals - Rename rclone globals for clarity
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
module mailclient
|
||||
|
||||
import incubaid.herolib.data.paramsparser
|
||||
import incubaid.herolib.data.encoderhero
|
||||
import os
|
||||
|
||||
pub const version = '0.0.0'
|
||||
const singleton = false
|
||||
const default = true
|
||||
|
||||
@[params]
|
||||
pub struct DefaultConfigArgs {
|
||||
instance string = 'default'
|
||||
}
|
||||
|
||||
pub fn heroscript_default(args DefaultConfigArgs) !string {
|
||||
mail_from := os.getenv_opt('MAIL_FROM') or { 'info@example.com' }
|
||||
mail_password := os.getenv_opt('MAIL_PASSWORD') or { 'secretpassword' }
|
||||
@@ -20,7 +26,7 @@ pub fn heroscript_default(args DefaultConfigArgs) !string {
|
||||
mail_password: '${mail_password}'
|
||||
mail_port: ${mail_port}
|
||||
mail_server: '${mail_server}'
|
||||
mail_username: '${mail_username}'
|
||||
mail_username: '${mail_username}'
|
||||
"
|
||||
|
||||
return heroscript
|
||||
@@ -55,3 +61,14 @@ fn obj_init(obj_ MailClient) !MailClient {
|
||||
mut obj := obj_
|
||||
return obj
|
||||
}
|
||||
|
||||
/////////////NORMALLY NO NEED TO TOUCH
|
||||
|
||||
pub fn heroscript_dumps(obj MailClient) !string {
|
||||
return encoderhero.encode[MailClient](obj)!
|
||||
}
|
||||
|
||||
pub fn heroscript_loads(heroscript string) !MailClient {
|
||||
mut obj := encoderhero.decode[MailClient](heroscript)!
|
||||
return obj
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user