---
source: boltffi_bindgen/src/render/csharp/templates.rs
expression: template.render().unwrap()
---
// <auto-generated>
// This file was generated by BoltFFI. Do not edit.
// </auto-generated>
#nullable enable

using System;
using System.Text;

namespace Demo
{
    public readonly record struct ServiceConfig(
        string Name,
        int Retries
    )
    {
        internal static ServiceConfig Decode(WireReader reader) =>
            new ServiceConfig(
                reader.ReadString(),
                reader.ReadI32()
            );

        internal int WireEncodedSize() =>
            (4 + Encoding.UTF8.GetByteCount(this.Name)) +
            4;

        internal void WireEncodeTo(WireWriter wire)
        {
            wire.WriteString(this.Name);
            wire.WriteI32(this.Retries);
        }

        public string Describe()
        {
            using var _wire_self = new WireWriter(this.WireEncodedSize());
            this.WireEncodeTo(_wire_self);
            byte[] _selfBytes = _wire_self.ToArray();
            FfiBuf _buf = NativeMethods.ServiceConfigDescribe(_selfBytes, (UIntPtr)_selfBytes.Length);
            try
            {
                return new WireReader(_buf).ReadString();
            }
            finally
            {
                NativeMethods.FreeBuf(_buf);
            }
        }
    }
}
