Class Leb128
Provides LEB128 related methods to integer types.
Inherited Members
Namespace: DotNext.Buffers.Binary
Assembly: DotNext.dll
Syntax
public static class Leb128
Methods
View SourceTryReadLeb128<T>(ReadOnlySpan<byte>, out T, out int)
Decodes LEB128-encoded integer.
Declaration
public static bool TryReadLeb128<T>(ReadOnlySpan<byte> buffer, out T result, out int bytesConsumed) where T : struct, IBinaryInteger<T>
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | buffer | The input buffer containing LEB128 octets. |
| T | result | The decoded value. |
| int | bytesConsumed | The number of bytes consumed from |
Returns
| Type | Description |
|---|---|
| bool |
Type Parameters
| Name | Description |
|---|---|
| T |
TryWriteLeb128<T>(T, Span<byte>, out int)
Tries to encode the value by using LEB128 binary format.
Declaration
public static bool TryWriteLeb128<T>(this T value, Span<byte> buffer, out int bytesWritten) where T : struct, IBinaryInteger<T>
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | |
| Span<byte> | buffer | The output buffer. |
| int | bytesWritten | The number of bytes written. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Type Parameters
| Name | Description |
|---|---|
| T |