[tor-commits] [stem/master] PackType enum
atagar at torproject.org
atagar at torproject.org
Sun Jan 21 02:04:03 UTC 2018
commit c9ea8a70622e80cf1ba9a960976244aa1a52ef73
Author: Damian Johnson <atagar at torproject.org>
Date: Mon Jan 1 16:40:30 2018 -0800
PackType enum
Enum for a more readable counterpart for endosome's PACK_FMT.
---
stem/client.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/stem/client.py b/stem/client.py
index e1011f96..4da12bba 100644
--- a/stem/client.py
+++ b/stem/client.py
@@ -9,6 +9,21 @@ providing higher level functions in much the same way as our
.. versionadded:: 1.7.0
+.. data:: PackType (enum)
+
+ Unsigned `struct.pack format
+ <https://docs.python.org/2/library/struct.html#format-characters>` for
+ network-order fields.
+
+ ==================== ===========
+ PackType Description
+ ==================== ===========
+ CHAR Unsigned char (1 byte)
+ SHORT Unsigned short (2 bytes)
+ LONG Unsigned long (4 bytes)
+ LONG_LONG Unsigned long long (8 bytes)
+ ==================== ===========
+
**Module Overview:**
::
@@ -16,6 +31,15 @@ providing higher level functions in much the same way as our
Relay - Connection with a relay's ORPort.
"""
+from stem.util import enum
+
+PackType = enum.Enum(
+ ('CHAR', '!B'), # 1 byte
+ ('SHORT', '!H'), # 2 bytes
+ ('LONG', '!L'), # 4 bytes
+ ('LONG_LONG', '!Q'), # 8 bytes
+)
+
class Relay(object):
"""
More information about the tor-commits
mailing list