Class ByteString
A rope-like immutable data structure containing bytes. The goal of this structure is to reduce copying of arrays when concatenating and slicing sequences of bytes, and also providing a thread safe way of working with bytes.
Inherited Members
Namespace: Akka.IO
Assembly: Akka.dll
Syntax
public sealed class ByteString : IEquatable<ByteString>, IEnumerable<byte>, IEnumerable
Properties
| Improve this Doc View SourceCount
Gets a total number of bytes stored inside this ByteString.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Empty
An empty ByteString.
Declaration
public static ByteString Empty { get; }
Property Value
Type | Description |
---|---|
ByteString |
IsCompact
Determines if current ByteString has compact representation. Compact byte strings represent bytes stored inside single, continuous block of memory.
Declaration
public bool IsCompact { get; }
Property Value
Type | Description |
---|---|
Boolean | TBD |
IsEmpty
Determines if current ByteString is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int32]
Gets a byte stored under a provided index
.
Declaration
public byte this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | TBD |
Property Value
Type | Description |
---|---|
Byte |
Methods
| Improve this Doc View SourceCompact()
Compacts current ByteString, potentially copying its content underneat into new byte array.
Declaration
public ByteString Compact()
Returns
Type | Description |
---|---|
ByteString | TBD |
Concat(ByteString)
Appends other
ByteString at the tail
of a current one, creating a new ByteString in result.
Contents of byte strings are NOT copied.
Declaration
public ByteString Concat(ByteString other)
Parameters
Type | Name | Description |
---|---|---|
ByteString | other |
Returns
Type | Description |
---|---|
ByteString | TBD |
CopyFrom(ArraySegment<Byte>)
Creates a new ByteString by copying a byte array range from provided buffer.
Declaration
public static ByteString CopyFrom(ArraySegment<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ArraySegment<Byte> | buffer | Buffer specifying a byte array range to copy. |
Returns
Type | Description |
---|---|
ByteString | A byte string representation of array of bytes. |
CopyFrom(Byte[])
Creates a new ByteString by copying a provided byte array.
Declaration
public static ByteString CopyFrom(byte[] array)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | array | Array of bytes to copy |
Returns
Type | Description |
---|---|
ByteString | A byte string representation of array of bytes. |
CopyFrom(Byte[], Int32, Int32)
Creates a new ByteString by copying a byte array.
Declaration
public static ByteString CopyFrom(byte[] array, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | array | Array of bytes to copy |
Int32 | offset | Index in provided |
Int32 | count | Number of bytes to copy. |
Returns
Type | Description |
---|---|
ByteString | TBD |
CopyFrom(IEnumerable<ArraySegment<Byte>>)
Creates a new ByteString by copying segments of bytes.
Declaration
public static ByteString CopyFrom(IEnumerable<ArraySegment<byte>> buffers)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ArraySegment<Byte>> | buffers |
Returns
Type | Description |
---|---|
ByteString |
CopyFrom(Memory<Byte>)
Creates a new ByteString by copying a System.Memory<T>.
Declaration
public static ByteString CopyFrom(Memory<byte> memory)
Parameters
Type | Name | Description |
---|---|---|
System.Memory<Byte> | memory | The System.Memory<T> to copy |
Returns
Type | Description |
---|---|
ByteString | The new ByteString |
CopyFrom(Memory<Byte>, Int32, Int32)
Creates a new ByteString by copying a System.Memory<T>.
Declaration
public static ByteString CopyFrom(Memory<byte> memory, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Memory<Byte> | memory | The System.Memory<T> to copy |
Int32 | offset | Index in provided |
Int32 | count | Number of bytes to copy. |
Returns
Type | Description |
---|---|
ByteString | The new ByteString |
CopyFrom(Span<Byte>)
Creates a new ByteString by copying a System.Span<T>.
Declaration
public static ByteString CopyFrom(Span<byte> span)
Parameters
Type | Name | Description |
---|---|---|
System.Span<Byte> | span | The System.Span<T> to copy |
Returns
Type | Description |
---|---|
ByteString | The new ByteString |
CopyFrom(Span<Byte>, Int32, Int32)
Creates a new ByteString by copying a System.Span<T>.
Declaration
public static ByteString CopyFrom(Span<byte> span, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Span<Byte> | span | The System.Span<T> to copy |
Int32 | offset | Index in provided |
Int32 | count | Number of bytes to copy. |
Returns
Type | Description |
---|---|
ByteString | The new ByteString |
CopyTo(Byte[], Int32, Int32)
Copies content of a current ByteString into a provided
buffer
starting from index
in that
buffer and copying a count
number of bytes.
Declaration
public int CopyTo(byte[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | |
Int32 | index | |
Int32 | count |
Returns
Type | Description |
---|---|
Int32 | TBD |
CopyTo(ref Memory<Byte>)
Copies content of a current ByteString into a provided System.Memory<T>
buffer
Declaration
public int CopyTo(ref Memory<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Memory<Byte> | buffer |
Returns
Type | Description |
---|---|
Int32 | The number of bytes copied |
CopyTo(ref Memory<Byte>, Int32, Int32)
Copies content of a current ByteString into a provided System.Memory<T>
buffer
starting from index
in that
buffer and copying a count
number of bytes.
Declaration
public int CopyTo(ref Memory<byte> buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Memory<Byte> | buffer | |
Int32 | index | |
Int32 | count |
Returns
Type | Description |
---|---|
Int32 | The number of bytes copied |
CopyTo(ref Span<Byte>)
Copies content of a current ByteString into a provided System.Span<T>
buffer
.
Declaration
public int CopyTo(ref Span<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Span<Byte> | buffer |
Returns
Type | Description |
---|---|
Int32 | The number of bytes copied |
CopyTo(ref Span<Byte>, Int32, Int32)
Copies content of a current ByteString into a provided System.Span<T>
buffer
starting from index
in that
buffer and copying a count
number of bytes.
Declaration
public int CopyTo(ref Span<byte> buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Span<Byte> | buffer | |
Int32 | index | |
Int32 | count |
Returns
Type | Description |
---|---|
Int32 | The number of bytes copied |
Equals(ByteString)
Declaration
public bool Equals(ByteString other)
Parameters
Type | Name | Description |
---|---|---|
ByteString | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceFromBytes(ArraySegment<Byte>)
Creates a new ByteString by wrapping raw range over array of bytes. WARNING: this method doesn't copy underlying array, but expects that represented range should not be modified once attached to byte string.
Declaration
public static ByteString FromBytes(ArraySegment<byte> buffer)
Parameters
Type | Name | Description |
---|---|---|
ArraySegment<Byte> | buffer | TBD |
Returns
Type | Description |
---|---|
ByteString | TBD |
FromBytes(Byte[])
Creates a new ByteString by wrapping raw array of bytes. WARNING: this method doesn't copy underlying array, but expects that it should not be modified once attached to byte string.
Declaration
public static ByteString FromBytes(byte[] array)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | array | TBD |
Returns
Type | Description |
---|---|
ByteString | TBD |
FromBytes(Byte[], Int32, Int32)
Creates a new ByteString by wrapping raw range over array of bytes. WARNING: this method doesn't copy underlying array, but expects that represented range should not be modified once attached to byte string.
Declaration
public static ByteString FromBytes(byte[] array, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | array | TBD |
Int32 | offset | TBD |
Int32 | count | TBD |
Returns
Type | Description |
---|---|
ByteString | TBD |
FromBytes(IEnumerable<ArraySegment<Byte>>)
Creates a new ByteString by wrapping raw collection of byte segements. WARNING: this method doesn't copy underlying arrays, but expects that represented range should not be modified once attached to byte string.
Declaration
public static ByteString FromBytes(IEnumerable<ArraySegment<byte>> buffers)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ArraySegment<Byte>> | buffers |
Returns
Type | Description |
---|---|
ByteString |
FromString(String)
Creates a new ByteString which will contain the UTF-8 representation of the given String
Declaration
public static ByteString FromString(string str)
Parameters
Type | Name | Description |
---|---|---|
String | str | TBD |
Returns
Type | Description |
---|---|
ByteString | TBD |
FromString(String, Encoding)
Creates a new ByteString which will contain the representation of the given String in the given charset encoding.
Declaration
public static ByteString FromString(string str, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
String | str | TBD |
Encoding | encoding | TBD |
Returns
Type | Description |
---|---|
ByteString | TBD |
GetEnumerator()
Declaration
public IEnumerator<byte> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<Byte> |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceHasSubstring(ByteString, Int32)
Checks if a subsequence determined by the other
byte string is can be found in current one, starting from provided
index
.
Declaration
public bool HasSubstring(ByteString other, int index)
Parameters
Type | Name | Description |
---|---|---|
ByteString | other | |
Int32 | index |
Returns
Type | Description |
---|---|
Boolean |
IndexOf(Byte)
Returns an index of the first occurence of provided byte starting from the beginning of the ByteString.
Declaration
public int IndexOf(byte b)
Parameters
Type | Name | Description |
---|---|---|
Byte | b |
Returns
Type | Description |
---|---|
Int32 |
IndexOf(Byte, Int32)
Returns an index of the first occurence of provided byte starting from the provided index.
Declaration
public int IndexOf(byte b, int from)
Parameters
Type | Name | Description |
---|---|---|
Byte | b | |
Int32 | from |
Returns
Type | Description |
---|---|
Int32 |
Slice(Int32)
Slices current ByteString, creating a new ByteString which contains a specified range of data from the original. This is non-copying operation.
Declaration
public ByteString Slice(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | index inside current ByteString, from which slicing should start |
Returns
Type | Description |
---|---|
ByteString |
Slice(Int32, Int32)
Slices current ByteString, creating a new ByteString which contains a specified range of data from the original. This is non-copying operation.
Declaration
public ByteString Slice(int index, int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | index inside current ByteString, from which slicing should start |
Int32 | count | Number of bytes to fit into new ByteString. |
Returns
Type | Description |
---|---|
ByteString |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | If index or count result in an invalid ByteString. |
ToArray()
Copies content of a current ByteString into a single byte array.
Declaration
public byte[] ToArray()
Returns
Type | Description |
---|---|
Byte[] | TBD |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
| Improve this Doc View SourceToString(Encoding)
Declaration
public string ToString(Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
Encoding | encoding |
Returns
Type | Description |
---|---|
String |
WriteTo(Stream)
Copies content of the current ByteString to a provided
writeable stream
.
Declaration
public void WriteTo(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream |
WriteToAsync(Stream)
Asynchronously copies content of the current ByteString
to a provided writeable stream
.
Declaration
public async Task WriteToAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream |
Returns
Type | Description |
---|---|
Task |
Operators
| Improve this Doc View SourceAddition(ByteString, ByteString)
Declaration
public static ByteString operator +(ByteString x, ByteString y)
Parameters
Type | Name | Description |
---|---|---|
ByteString | x | |
ByteString | y |
Returns
Type | Description |
---|---|
ByteString |
Equality(ByteString, ByteString)
Declaration
public static bool operator ==(ByteString x, ByteString y)
Parameters
Type | Name | Description |
---|---|---|
ByteString | x | |
ByteString | y |
Returns
Type | Description |
---|---|
Boolean |
Explicit(ByteString to Byte[])
Declaration
public static explicit operator byte[](ByteString byteString)
Parameters
Type | Name | Description |
---|---|---|
ByteString | byteString |
Returns
Type | Description |
---|---|
Byte[] |
Explicit(Byte[] to ByteString)
Declaration
public static explicit operator ByteString(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | bytes |
Returns
Type | Description |
---|---|
ByteString |
Inequality(ByteString, ByteString)
Declaration
public static bool operator !=(ByteString x, ByteString y)
Parameters
Type | Name | Description |
---|---|---|
ByteString | x | |
ByteString | y |
Returns
Type | Description |
---|---|
Boolean |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |