Struct BencodeSpanWriter
Represents a writer that provides generation of bencoded data.
Inherited Members
System.ValueType.Equals(System.Object)
System.ValueType.GetHashCode()
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: ItsyBitsy.Bencoding
Assembly: ItsyBitsy.Bencoding.dll
Syntax
public struct BencodeSpanWriter
Constructors
| Improve this Doc View SourceBencodeSpanWriter(IBufferWriter<Byte>, Boolean)
Initializes a new BencodeSpanWriter instance using the specified
destination buffer.
Declaration
public BencodeSpanWriter(IBufferWriter<byte> destination, bool skipValidation = false)
Parameters
Type | Name | Description |
---|---|---|
System.Buffers.IBufferWriter<System.Byte> | destination | The destination to write the encoded data into. |
System.Boolean | skipValidation | If true, keys are not checked for mis-ordering and duplication as they are being written. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | destination is
null. |
BencodeSpanWriter(Span<Byte>, Boolean)
Initializes a new BencodeSpanWriter instance using the specified
destination buffer.
Declaration
public BencodeSpanWriter(Span<byte> destination, bool skipValidation = false)
Parameters
Type | Name | Description |
---|---|---|
System.Span<System.Byte> | destination | The destination to write the encoded data into. |
System.Boolean | skipValidation | If true, keys are not checked for mis-ordering and duplication as they are being written. |
Properties
| Improve this Doc View SourceBufferedLength
Gets the number of bytes that have been written but not yet flushed to the underlying
System.Buffers.IBufferWriter<T>.
Declaration
public int BufferedLength { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
If BencodeSpanWriter was constructed with a System.Span<T> as the
destination then BufferedLength is the number of bytes written to the
System.Span<T>.
Methods
| Improve this Doc View SourceDispose()
Restores the state of the parent writer.
Declaration
public void Dispose()
Remarks
It is only necessary to call Dispose() if the
BencodeSpanWriter was created using
CreateSpanWriter().
|
Improve this Doc
View Source
Flush(Boolean)
Advances the underlying System.Buffers.IBufferWriter<T>.
Declaration
public void Flush(bool final = true)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | final | Indicates whether the value should be complete. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | final is
true and the value is incomplete. |
WriteDictionaryHead()
Writes the beginning of a dictionary.
Declaration
public void WriteDictionaryHead()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The writer is not in a state that allows a dictionary head to be written. |
System.InvalidOperationException | The writer reached the end of the destination buffer while writing the dictionary head. |
WriteDictionaryTail()
Writes the end of a dictionary.
Declaration
public void WriteDictionaryTail()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The writer is not in a state that allows a dictionary tail to be written. |
System.InvalidOperationException | The writer reached the end of the destination buffer while writing the dictionary tail. |
WriteInteger(Int64)
Writes an integer.
Declaration
public void WriteInteger(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The integer to write. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The writer is not in a state that allows an integer to be written. |
System.InvalidOperationException | The writer reached the end of the destination buffer while writing the integer. |
WriteKey(ReadOnlySpan<Byte>)
Writes a key.
Declaration
public void WriteKey(ReadOnlySpan<byte> key)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Byte> | key | The key to write. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The writer is not in a state that allows a key to be written. |
System.InvalidOperationException | The writer reached the end of the destination buffer while writing the key. |
System.InvalidOperationException | The writer was constructed with validation enabled and the key being written is mis-ordered or duplicated. |
WriteListHead()
Writes the beginning of a list.
Declaration
public void WriteListHead()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The writer is not in a state that allows a list head to be written. |
System.InvalidOperationException | The writer reached the end of the destination buffer while writing the list head. |
WriteListTail()
Writes the end of a list.
Declaration
public void WriteListTail()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The writer is not in a state that allows a list tail to be written. |
System.InvalidOperationException | The writer reached the end of the destination buffer while writing the list tail. |
WriteString(ReadOnlySpan<Byte>)
Writes a string.
Declaration
public void WriteString(ReadOnlySpan<byte> value)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Byte> | value | The string to write. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The writer is not in a state that allows a string to be written. |
System.InvalidOperationException | The writer reached the end of the destination buffer while writing the string. |