Files
herolib/lib/clients/zinit/zinit_model.v
2025-10-12 12:30:19 +03:00

49 lines
1.0 KiB
V

module zinit
import incubaid.herolib.data.encoderhero
import incubaid.herolib.schemas.jsonrpc
import os
pub const version = '0.0.0'
const singleton = true
const default = false
// // Factory function to create a new ZinitRPC client instance
// @[params]
// pub struct NewClientArgs {
// pub mut:
// name string = 'default'
// socket_path string
// }
// pub fn new_client(args NewClientArgs) !&ZinitRPC {
// mut client := ZinitRPC{
// name: args.name
// socket_path: args.socket_path
// }
// client = obj_init(client)!
// return &client
// }
@[heap]
pub struct ZinitRPC {
pub mut:
name string = 'default'
socket_path string
// rpc_client ?&jsonrpc.Client @[skip]
}
// your checking & initialization code if needed
fn obj_init(mycfg_ ZinitRPC) !ZinitRPC {
mut mycfg := mycfg_
if mycfg.socket_path == '' {
mycfg.socket_path = '/tmp/zinit.sock'
}
return mycfg
}
pub fn heroscript_loads(heroscript string) !ZinitRPC {
mut obj := encoderhero.decode[ZinitRPC](heroscript)!
return obj
}