Skip to content

Commit cfc1d75

Browse files
author
GuangChen2333
committed
doc(README): Update README.md
1 parent ffae9a4 commit cfc1d75

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,37 @@ class PackA(Pack):
3030
s: FixedString = (b"hello", 10)
3131
t: LengthPrefixedString = b"world"
3232
u: UnsignedPointer = 0x0d000721
33-
33+
v: bytes = b'raw_bytes'
3434

3535
r = PackA.build(endianness=Endianness.NATIVE)
36-
print(r)
36+
hex_list = [format(byte, '02x') for byte in r]
37+
hex_str = ' '.join(hex_list)
38+
print(hex_str)
3739
```
3840

3941
And you will get:
4042

4143
```text
42-
b'\x00A\xff\x01\x00\xfe\xff\x02\x00\xfd\xff\xff\xff\x03\x00\x00\x00\xfc\xff\xff\xff\x04\x00\x00\x00\xfb\xff\xff\xff\xff\xff\xff\xff\x05\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x00\x00\x00HB\xc3\xf5H@\x1f\x85\xebQ\xb8\x1e\t@hello\x00\x00\x00\x00\x00\x05world!\x07\x00\r\x00\x00\x00\x00'
44+
00 41 ff 01 00 fe ff 02 00 fd ff ff ff 03 00 00 00 fc ff ff ff 04 00 00 00 fb ff ff ff ff ff ff ff 05 00 00 00 00 00 00 00 0c 00 00 00 00 00 00 00 22 00 00 00 00 00 00 00 48 42 c3 f5 48 40 1f 85 eb 51 b8 1e 09 40 68 65 6c 6c 6f 00 00 00 00 00 05 77 6f 72 6c 64 21 07 00 0d 00 00 00 00 72 61 77 5f 62 79 74 65 73
45+
```
46+
47+
## Advance
48+
49+
### Supported Endianness
50+
- `Endianness.BIG`: Big-endian
51+
- `Endianness.LITTLE`: Little-endian
52+
- `Endianness.NETWORK`: Big-endian
53+
- `Endianness.NATIVE`: Depend on your device (Default)
54+
55+
### Custom Data Types
56+
57+
You can define your own data types by simply inheriting the `BaseType` class:
58+
59+
```python
60+
from structovo import BaseType, Endianness
61+
62+
63+
class MyDataType(BaseType):
64+
def encode(self, endianness: Endianness) -> bytes:
65+
return ...
4366
```

0 commit comments

Comments
 (0)