- 结构体
结构体
io 包中定义了下面几个结构体:
- ByteReader
- ByteWriter
- RawReader
- Reader
- Writer
它们之间的关系是:
+---------------------------------------------------------+
| _ _ _ _ |
| | | | | (_) | |
| | | | |_ __ _| |_ ___ _ __ |
| | |/\| | '__| | __/ _ \ '__| |
| \ /\ / | | | || __/ | |
| \/ \/|_| |_|\__\___|_| |
| |
| +-----------------------------------------------------+ |
| | ______ _ _ _ _ _ | |
| | | ___ \ | | | | | | (_) | | |
| | | |_/ /_ _| |_ ___ | | | |_ __ _| |_ ___ _ __ | |
| | | ___ \ | | | __/ _ \| |/\| | '__| | __/ _ \ '__| | |
| | | |_/ / |_| | || __/\ /\ / | | | || __/ | | |
| | \____/ \__, |\__\___| \/ \/|_| |_|\__\___|_| | |
| | __/ | | |
| | |___/ | |
| +-----------------------------------------------------+ |
+---------------------------------------------------------+
+-------------------------------------------------------------+
| ______ _ |
| | ___ \ | | |
| | |_/ /___ __ _ __| | ___ _ __ |
| | // _ \/ _` |/ _` |/ _ \ '__| |
| | |\ \ __/ (_| | (_| | __/ | |
| \_| \_\___|\__,_|\__,_|\___|_| |
| |
| +---------------------------------------------------------+ |
| | ______ ______ _ | |
| | | ___ \ | ___ \ | | | |
| | | |_/ /__ ___ _| |_/ /___ __ _ __| | ___ _ __ | |
| | | // _` \ \ /\ / / // _ \/ _` |/ _` |/ _ \ '__| | |
| | | |\ \ (_| |\ V V /| |\ \ __/ (_| | (_| | __/ | | |
| | \_| \_\__,_| \_/\_/ \_| \_\___|\__,_|\__,_|\___|_| | |
| | +-----------------------------------------------------+ | |
| | |______ _ ______ _ | | |
| | || ___ \ | | | ___ \ | | | | |
| | || |_/ /_ _| |_ ___| |_/ /___ __ _ __| | ___ _ __ | | |
| | || ___ \ | | | __/ _ \ // _ \/ _` |/ _` |/ _ \ '__|| | |
| | || |_/ / |_| | || __/ |\ \ __/ (_| | (_| | __/ | | | |
| | |\____/ \__, |\__\___\_| \_\___|\__,_|\__,_|\___|_| | | |
| | | __/ | | | |
| | | |___/ | | |
| | +-----------------------------------------------------+ | |
| +---------------------------------------------------------+ |
+-------------------------------------------------------------+
其中 ByteReader
和 ByteWriter
是用于对字节序列的读写,它本身跟 hprose 序列化无关,可以单独作为字节序列读写的工具来用,因为是读写分离的,所以性能上要比 bytes
包下面的那几个用于对字节序列化读写的结构体高效一点点,但是功能也少一些。
RawReader
用于读取 hprose 的原始数据,用户通常不需要使用该结构体。
Writer
和 Reader
用于对数据进行 hprose 的细粒度序列化和反序列化操作。
- ByteWriter
- Reader
- ByteReader
- Writer