# ``twisted`.`names`.`dns`.`IEncodable``

interface documentation

`class IEncodable(Interface): (source)`

Known subclasses: `twisted.names.dns.IEncodableRecord`

Known implementations: `twisted.names.dns.Charstr`, `twisted.names.dns.Name`, `twisted.names.dns.Query`, `twisted.names.dns.RRHeader`, `twisted.names.dns._OPTHeader`, `twisted.names.dns._OPTVariableOption`

View In Hierarchy

Interface for something which can be encoded to and decoded to the DNS wire format.

A binary-mode file object (such as `io.BytesIO`) is used as a buffer when encoding or decoding.

Method | `decode` | Reconstruct an object from data read from the given file object.
Method | `encode` | Write a representation of this object to the given file object.

def decode(strio, length=None): (source)
Reconstruct an object from data read from the given file object.

Parameters
strio:File-like object | A seekable buffer from which bytes may be read.
length:`int` or `None` | The number of bytes in this RDATA field. Most implementations can ignore this value. Only in the case of records similar to TXT where the total length is in no way encoded in the data is it necessary.

def encode(strio, compDict=None): (source)
Write a representation of this object to the given file object.

Parameters
strio:File-like object | The buffer to write to. It must have a `tell()` method.
compDict:`dict` of `bytes` to `int` r `None` | A mapping of names to byte offsets that have already been written to the buffer, which may be used for compression (see RFC 1035 section 4.1.4). When `None`, encode without compression.