Skip to content

Commit 504c89d

Browse files
committed
remove system namespace prefix from spans
1 parent 782896e commit 504c89d

4 files changed

Lines changed: 28 additions & 7 deletions

File tree

core/Address.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct Address : IEquatable<Address>
1010
{
1111
private ASCIIText256 value;
1212

13-
public readonly byte Length => value.Length;
13+
public readonly int Length => value.Length;
1414

1515
public Address(ASCIIText256 value)
1616
{
@@ -22,7 +22,7 @@ public Address(string value)
2222
this.value = new(value);
2323
}
2424

25-
public Address(System.Span<char> value)
25+
public Address(ReadOnlySpan<char> value)
2626
{
2727
this.value = new(value);
2828
}

core/Components/IsDataRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public struct IsDataRequest
99
public RequestStatus status;
1010
public TimeSpan timeout;
1111

12-
public IsDataRequest(System.Span<char> address, RequestStatus status, TimeSpan timeout)
12+
public IsDataRequest(ReadOnlySpan<char> address, RequestStatus status, TimeSpan timeout)
1313
{
1414
this.address = new(address);
1515
this.status = status;

core/DataRequest.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ namespace Data
1515
public readonly Address Address => GetComponent<IsDataRequest>().address;
1616
public readonly bool IsLoaded => GetComponent<IsDataRequest>().status == RequestStatus.Loaded;
1717

18-
public readonly System.Span<byte> Bytes
18+
/// <summary>
19+
/// Bytes of the loaded data.
20+
/// </summary>
21+
public readonly ReadOnlySpan<byte> Bytes
1922
{
2023
get
2124
{
@@ -31,7 +34,7 @@ readonly void IEntity.Describe(ref Archetype archetype)
3134
archetype.AddArrayType<BinaryData>();
3235
}
3336

34-
public DataRequest(World world, System.Span<char> address, TimeSpan timeout = default)
37+
public DataRequest(World world, ReadOnlySpan<char> address, TimeSpan timeout = default)
3538
{
3639
this.world = world;
3740
value = world.CreateEntity(new IsDataRequest(address, RequestStatus.Submitted, timeout));
@@ -60,7 +63,10 @@ public readonly override string ToString()
6063
return Address.ToString();
6164
}
6265

63-
public readonly bool TryGetData(out System.Span<byte> data)
66+
/// <summary>
67+
/// Tries to retrieve the data if its loaded.
68+
/// </summary>
69+
public readonly bool TryGetData(out ReadOnlySpan<byte> data)
6470
{
6571
if (IsLoaded)
6672
{

core/Message/LoadData.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Data.Messages
2626
/// <summary>
2727
/// Loaded bytes.
2828
/// </summary>
29-
public readonly System.Span<byte> Bytes
29+
public readonly ReadOnlySpan<byte> Bytes
3030
{
3131
get
3232
{
@@ -83,6 +83,21 @@ public readonly LoadData BecomeLoaded(ByteReader loadedData)
8383
return new LoadData(world, address, loadedData);
8484
}
8585

86+
/// <summary>
87+
/// Tries to retrieve the loaded bytes.
88+
/// </summary>
89+
public readonly bool TryGetBytes(out ReadOnlySpan<byte> data)
90+
{
91+
if (!loadedData.IsDisposed)
92+
{
93+
data = loadedData.GetBytes();
94+
return true;
95+
}
96+
97+
data = default;
98+
return false;
99+
}
100+
86101
[Conditional("DEBUG")]
87102
private readonly void ThrowIfNotLoaded()
88103
{

0 commit comments

Comments
 (0)