File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments