Show / Hide Table of Contents

Class Leb128

Provides LEB128 related methods to integer types.

Inheritance
object
Leb128
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.Buffers.Binary
Assembly: DotNext.dll
Syntax
public static class Leb128

Methods

View Source

TryReadLeb128<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 buffer.

Returns
Type Description
bool

true if operation is successful; otherwise, false.

Type Parameters
Name Description
T
View Source

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 buffer has enough space to save the encoded value; otherwise, false.

Type Parameters
Name Description
T
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾