#nullable enable
namespace
BitsDemo
{
/// <remarks> <list type="table">
/// <item> <term><b>Field</b></term> <description><b>Byte Length</b></description> </item>
/// <item> <term><see cref="cmf"/></term> <description>1</description> </item>
/// <item> <term><see cref="flg"/></term> <description>1</description> </item>
/// <item> <term> --- </term> <description>2</description> </item>
/// </list> </remarks>
partial record zlib_header : global::Darp.BinaryObjects.IWritable, global::Darp.BinaryObjects.ISpanReadable<zlib_header>
{
/// <inheritdoc />
[global::System.Diagnostics.Contracts.Pure]
[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
int
GetByteCount() => 2;
/// <inheritdoc />
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
bool
TryWriteLittleEndian(global::System.Span<
byte
> destination) => TryWriteLittleEndian(destination,
out
_);
/// <inheritdoc />
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
bool
TryWriteLittleEndian(global::System.Span<
byte
> destination,
out
int
bytesWritten)
{
bytesWritten = 0;
if
(destination.Length < 2)
return
false
;
global::Darp.BinaryObjects.Generated.Utilities.WriteUInt8(destination[0..],
this
.cmf);
global::Darp.BinaryObjects.Generated.Utilities.WriteUInt8(destination[1..],
this
.flg);
bytesWritten += 2;
return
true
;
}
/// <inheritdoc />
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
bool
TryWriteBigEndian(global::System.Span<
byte
> destination) => TryWriteBigEndian(destination,
out
_);
/// <inheritdoc />
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
bool
TryWriteBigEndian(global::System.Span<
byte
> destination,
out
int
bytesWritten)
{
bytesWritten = 0;
if
(destination.Length < 2)
return
false
;
global::Darp.BinaryObjects.Generated.Utilities.WriteUInt8(destination[0..],
this
.cmf);
global::Darp.BinaryObjects.Generated.Utilities.WriteUInt8(destination[1..],
this
.flg);
bytesWritten += 2;
return
true
;
}
/// <inheritdoc />
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
static
bool
TryReadLittleEndian(global::System.ReadOnlySpan<
byte
> source, [global::System.Diagnostics.CodeAnalysis.NotNullWhen(
true
)]
out
zlib_header? value) => TryReadLittleEndian(source,
out
value,
out
_);
/// <inheritdoc />
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
static
bool
TryReadLittleEndian(global::System.ReadOnlySpan<
byte
> source, [global::System.Diagnostics.CodeAnalysis.NotNullWhen(
true
)]
out
zlib_header? value,
out
int
bytesRead)
{
bytesRead = 0;
value =
default
;
if
(source.Length < 2)
return
false
;
var
___readcmf = global::Darp.BinaryObjects.Generated.Utilities.ReadUInt8(source[0..1]);
var
___readflg = global::Darp.BinaryObjects.Generated.Utilities.ReadUInt8(source[1..2]);
bytesRead += 2;
value =
new
zlib_header(___readcmf, ___readflg);
return
true
;
}
/// <inheritdoc />
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
static
bool
TryReadBigEndian(global::System.ReadOnlySpan<
byte
> source, [global::System.Diagnostics.CodeAnalysis.NotNullWhen(
true
)]
out
zlib_header? value) => TryReadBigEndian(source,
out
value,
out
_);
/// <inheritdoc />
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
public
static
bool
TryReadBigEndian(global::System.ReadOnlySpan<
byte
> source, [global::System.Diagnostics.CodeAnalysis.NotNullWhen(
true
)]
out
zlib_header? value,
out
int
bytesRead)
{
bytesRead = 0;
value =
default
;
if
(source.Length < 2)
return
false
;
var
___readcmf = global::Darp.BinaryObjects.Generated.Utilities.ReadUInt8(source[0..1]);
var
___readflg = global::Darp.BinaryObjects.Generated.Utilities.ReadUInt8(source[1..2]);
bytesRead += 2;
value =
new
zlib_header(___readcmf, ___readflg);
return
true
;
}
}
}
namespace
Darp.BinaryObjects.Generated
{
using
Darp.BinaryObjects;
using
System;
using
System.Buffers.Binary;
using
System.CodeDom.Compiler;
using
System.Collections.Generic;
using
System.Runtime.CompilerServices;
using
System.Runtime.InteropServices;
/// <summary>Helper methods used by generated BinaryObjects.</summary>
[GeneratedCodeAttribute(
"Darp.BinaryObjects.Generator"
,
"0.4.0.0"
)]
file
static
class
Utilities
{
/// <summary> Writes a <c>byte</c> to the destination </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public
static
void
WriteUInt8(Span<
byte
> destination,
byte
value)
{
destination[0] = value;
}
/// <summary> Reads a <c>byte</c> from the given source </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public
static
byte
ReadUInt8(ReadOnlySpan<
byte
> source)
{
return
source[0];
}
}
}