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:
Mahmoud-Emad
2025-10-13 21:49:19 +03:00
parent 25fbc61f49
commit f789564f51
21 changed files with 268 additions and 99 deletions

View File

@@ -2,7 +2,6 @@ module ipapi
import incubaid.herolib.core.base
import incubaid.herolib.core.playbook { PlayBook }
import incubaid.herolib.ui.console
import json
__global (

View File

@@ -1,8 +1,8 @@
module ipapi
import incubaid.herolib.data.paramsparser
import incubaid.herolib.data.encoderhero
import incubaid.herolib.core.httpconnection
import os
pub const version = '1.14.3'
const singleton = false
@@ -11,7 +11,7 @@ const default = true
// TODO: THIS IS EXAMPLE CODE AND NEEDS TO BE CHANGED IN LINE TO STRUCT BELOW, IS STRUCTURED AS HEROSCRIPT
pub fn heroscript_default() !string {
heroscript := "
!!ipapi.configure
!!ipapi.configure
name:'default'
"
@@ -24,7 +24,6 @@ pub fn heroscript_default() !string {
pub struct IPApi {
pub mut:
name string = 'default'
conn ?&httpconnection.HTTPConnection @[str: skip]
}
@@ -42,6 +41,17 @@ fn obj_init(obj_ IPApi) !IPApi {
return obj
}
/////////////NORMALLY NO NEED TO TOUCH
pub fn heroscript_dumps(obj IPApi) !string {
return encoderhero.encode[IPApi](obj)!
}
pub fn heroscript_loads(heroscript string) !IPApi {
mut obj := encoderhero.decode[IPApi](heroscript)!
return obj
}
pub fn (mut client IPApi) connection() !&httpconnection.HTTPConnection {
mut c := client.conn or {
mut c2 := httpconnection.new(