Class ReadOnlyMemoryExtensions
- Namespace
- Plugin.ByteArrays
- Assembly
- Plugin.ByteArrays.dll
Functions for working with ReadOnlyMemory<byte> providing memory-safe operations for reading and manipulating byte data.
public static class ReadOnlyMemoryExtensions
- Inheritance
-
ReadOnlyMemoryExtensions
- Inherited Members
Methods
EndsWith(ReadOnlyMemory<byte>, ReadOnlySpan<byte>)
Determines whether the ReadOnlyMemory<byte> ends with the specified pattern.
public static bool EndsWith(this ReadOnlyMemory<byte> memory, ReadOnlySpan<byte> pattern)
Parameters
memoryReadOnlyMemory<byte>The memory to check.
patternReadOnlySpan<byte>The pattern to check for at the end of the memory.
Returns
- bool
True if the memory ends with the specified pattern; otherwise, false.
IndexOf(ReadOnlyMemory<byte>, ReadOnlySpan<byte>)
Finds the first occurrence of a pattern in a ReadOnlyMemory<byte>.
public static int IndexOf(this ReadOnlyMemory<byte> memory, ReadOnlySpan<byte> pattern)
Parameters
memoryReadOnlyMemory<byte>The memory to search in.
patternReadOnlySpan<byte>The pattern to search for.
Returns
- int
The index of the first occurrence, or -1 if not found.
IsIdenticalTo(ReadOnlyMemory<byte>, ReadOnlyMemory<byte>)
Checks if two ReadOnlyMemory<byte> instances are identical in content and length.
public static bool IsIdenticalTo(this ReadOnlyMemory<byte> memory1, ReadOnlyMemory<byte> memory2)
Parameters
memory1ReadOnlyMemory<byte>First ReadOnlyMemory<byte>.
memory2ReadOnlyMemory<byte>Second ReadOnlyMemory<byte>.
Returns
- bool
True if memory regions are identical; otherwise, false.
StartsWith(ReadOnlyMemory<byte>, ReadOnlySpan<byte>)
Checks if a ReadOnlyMemory<byte> starts with a specific pattern.
public static bool StartsWith(this ReadOnlyMemory<byte> memory, ReadOnlySpan<byte> pattern)
Parameters
memoryReadOnlyMemory<byte>The memory to check.
patternReadOnlySpan<byte>The pattern to look for.
Returns
- bool
True if the memory starts with the pattern, false otherwise.
ToDebugString(ReadOnlyMemory<byte>)
Converts the ReadOnlyMemory<byte> into a readable string for debugging purposes. Each byte is represented as a decimal value, separated by commas.
public static string ToDebugString(this ReadOnlyMemory<byte> memory)
Parameters
memoryReadOnlyMemory<byte>The ReadOnlyMemory<byte> to process.
Returns
- string
A string representing the memory as comma-separated decimal numbers.
ToHexDebugString(ReadOnlyMemory<byte>)
Converts the given ReadOnlyMemory<byte> to its hexadecimal string representation for debugging. Each byte is represented as a two-digit hex value, separated by commas.
public static string ToHexDebugString(this ReadOnlyMemory<byte> memory)
Parameters
memoryReadOnlyMemory<byte>The ReadOnlyMemory<byte> to process.
Returns
- string
A string representing the memory as comma-separated hex numbers.