rust结构体指针使用和强制转换的问题
在C语言中,结构体指针可以快速处理二进制数据,例如:
typedef struct _student{
UINT8 username;
UINT8 age;
}_student,*student;
the_student = (student)Data;
the_student->username = "a";
the_student->age = "b";
如上述代码,请教一下,这个数据的转换和操作在rust中该如何实现?例如在TCP中,将stream.read的buffer数据进行结构体的转换。从而进行数据的操作,目前找了serde等第三方库,觉得太复杂,不知有没最直接的方式实现?谢谢。
推荐文章: