Hi, I just discovered Nim and already doing little toy projects with it to get used to it. Love it.
I am playing with networking. But reading from raw sockets, I need to cast the string to a tuple which represent the headers fields. That would enable me to select any field of the ethernet/ip/udp frame more easily. I have: type Raw_Frame = tuple mac_dest: array[6,char] mac_src: array[6,char] var t : ref Raw_Frame var data_coming_from_socket : string = "123456789123" #Imagine that the string comes from recv t = cast[ref Raw_Frame](addr c) echo("hi ", t.mac_dest,t.mac_src) Run nim I want t.mac_dest = ['1','2','3','4','5','6'] and t.mac_src = ['7','8','9','1','2','3'] as an array of char Then, different types will follow but I wanted my question to remain concise. Ultimately, I would cast the string to a tuple (I don't want objects, too much overhead) In C, you just cast your array of uint8 to a structure pointer and call it a day. Sure Nim does that too. I understood that string is actually a pointer but not too sure. If you have a better idea as to how to do it the Nim way, please help! Thanks,