Table of Contents

Struct Reader

Namespace
Tmds.DBus.Protocol
Assembly
Tmds.DBus.Protocol.dll

Provides methods for reading a D-Bus message.

public ref struct Reader
Inherited Members

Methods

AlignStruct()

Aligns the reader to a struct boundary.

public void AlignStruct()

HasNext(ArrayEnd)

Checks if there are more elements to read in the array.

public bool HasNext(ArrayEnd iterator)

Parameters

iterator ArrayEnd

The ArrayEnd iterator returned by ReadArrayStart(DBusType).

Returns

bool

true if there are more elements to read; otherwise, false.

ReadArrayOfBool()

Reads an array of booleans.

public bool[] ReadArrayOfBool()

Returns

bool[]

ReadArrayOfByte()

Reads an array of bytes.

public byte[] ReadArrayOfByte()

Returns

byte[]

ReadArrayOfDouble()

Reads an array of double values.

public double[] ReadArrayOfDouble()

Returns

double[]

ReadArrayOfHandle<T>()

Reads an array of Unix file descriptor handles.

public T[] ReadArrayOfHandle<T>() where T : SafeHandle, new()

Returns

T[]

Type Parameters

T

The SafeHandle type to read.

ReadArrayOfInt16()

Reads an array of signed 16-bit integers.

public short[] ReadArrayOfInt16()

Returns

short[]

ReadArrayOfInt32()

Reads an array of signed 32-bit integers.

public int[] ReadArrayOfInt32()

Returns

int[]

ReadArrayOfInt64()

Reads an array of signed 64-bit integers.

public long[] ReadArrayOfInt64()

Returns

long[]

ReadArrayOfObjectPath()

Reads an array of object paths.

public ObjectPath[] ReadArrayOfObjectPath()

Returns

ObjectPath[]

ReadArrayOfSignature()

Reads an array of signatures.

public Signature[] ReadArrayOfSignature()

Returns

Signature[]

ReadArrayOfString()

Reads an array of strings.

public string[] ReadArrayOfString()

Returns

string[]

ReadArrayOfUInt16()

Reads an array of unsigned 16-bit integers.

public ushort[] ReadArrayOfUInt16()

Returns

ushort[]

ReadArrayOfUInt32()

Reads an array of unsigned 32-bit integers.

public uint[] ReadArrayOfUInt32()

Returns

uint[]

ReadArrayOfUInt64()

Reads an array of unsigned 64-bit integers.

public ulong[] ReadArrayOfUInt64()

Returns

ulong[]

ReadArrayOfVariantValue()

Reads an array of variant values.

public VariantValue[] ReadArrayOfVariantValue()

Returns

VariantValue[]

ReadArrayStart(DBusType)

Reads the start of an array and returns a position for detecting the end.

public ArrayEnd ReadArrayStart(DBusType elementType)

Parameters

elementType DBusType

The type of array elements.

Returns

ArrayEnd

ReadBool()

Reads a boolean value.

public bool ReadBool()

Returns

bool

ReadByte()

Reads a byte value.

public byte ReadByte()

Returns

byte

ReadDictionaryOfStringToVariantValue()

Reads a dictionary with string keys and VariantValue values.

public Dictionary<string, VariantValue> ReadDictionaryOfStringToVariantValue()

Returns

Dictionary<string, VariantValue>

Remarks

This is a helper method for reading the common 'a{sv}' D-Bus type.

ReadDictionaryStart()

Reads the start of a dictionary and returns a position for detecting the end.

public ArrayEnd ReadDictionaryStart()

Returns

ArrayEnd

ReadDouble()

Reads a double.

public double ReadDouble()

Returns

double

ReadHandleRaw()

Reads a Unix file descriptor handle as a raw IntPtr.

public IntPtr ReadHandleRaw()

Returns

IntPtr

Remarks

A handle can only be read once. To skip reading a handle, call ReadHandle<SkipSafeHandle>(), which will return a disposed SkipSafeHandle instance without consuming the underlying handle. The handle is still owned (i.e. Disposed) by the Message.

Exceptions

DBusReadException

The file descriptor is not present in the message.

DBusUnexpectedValueException

The handle was already read.

ReadHandle<T>()

Reads a Unix file descriptor handle.

public T ReadHandle<T>() where T : SafeHandle, new()

Returns

T

Type Parameters

T

The SafeHandle type to read. If T is SkipSafeHandle, the method returns a disposed SkipSafeHandle instance without consuming the underlying handle.

Remarks

A handle can only be read once. Use SkipSafeHandle to avoid consuming the handle.

Exceptions

DBusReadException

The file descriptor is not present in the message.

DBusUnexpectedValueException

The handle was already read.

ReadInt16()

Reads a signed 16-bit integer.

public short ReadInt16()

Returns

short

ReadInt32()

Reads a signed 32-bit integer.

public int ReadInt32()

Returns

int

ReadInt64()

Reads a signed 64-bit integer.

public long ReadInt64()

Returns

long

ReadObjectPath()

Reads an object path.

public ObjectPath ReadObjectPath()

Returns

ObjectPath

ReadObjectPathAsSpan()

Reads an object path as a byte span.

public ReadOnlySpan<byte> ReadObjectPathAsSpan()

Returns

ReadOnlySpan<byte>

ReadObjectPathAsString()

Reads an object path as a string.

public string ReadObjectPathAsString()

Returns

string

ReadSignature()

Reads a signature.

public Signature ReadSignature()

Returns

Signature

ReadSignature(ReadOnlySpan<byte>)

Reads and validates a signature matches the expected value.

public void ReadSignature(ReadOnlySpan<byte> expected)

Parameters

expected ReadOnlySpan<byte>

The expected signature.

ReadSignature(string)

Reads and validates a signature matches the expected value.

public void ReadSignature(string expected)

Parameters

expected string

The expected signature string.

ReadSignatureAsSpan()

Reads a signature as a byte span.

public ReadOnlySpan<byte> ReadSignatureAsSpan()

Returns

ReadOnlySpan<byte>

ReadSignatureAsString()

Reads a signature as a string.

public string ReadSignatureAsString()

Returns

string

ReadString()

Reads a string.

public string ReadString()

Returns

string

ReadStringAsSpan()

Reads a string as a byte span.

public ReadOnlySpan<byte> ReadStringAsSpan()

Returns

ReadOnlySpan<byte>

ReadUInt16()

Reads an unsigned 16-bit integer.

public ushort ReadUInt16()

Returns

ushort

ReadUInt32()

Reads an unsigned 32-bit integer.

public uint ReadUInt32()

Returns

uint

ReadUInt64()

Reads an unsigned 64-bit integer.

public ulong ReadUInt64()

Returns

ulong

ReadVariantValue()

Reads a variant value.

public VariantValue ReadVariantValue()

Returns

VariantValue

The variant value.

SkipTo(ArrayEnd)

Skips to the end of the array.

public void SkipTo(ArrayEnd end)

Parameters

end ArrayEnd

The ArrayEnd iterator returned by ReadArrayStart(DBusType).