---
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;

namespace Demo
{
    public enum Direction : int
    {
        North = 0,
        South = 1,
        East = 2,
        West = 3
    }

    internal static class DirectionWire
    {
        internal const int WireEncodedSize = 4;

        internal static Direction Decode(WireReader reader) =>
            reader.ReadI32() switch
            {
                0 => Direction.North,
                1 => Direction.South,
                2 => Direction.East,
                3 => Direction.West,
                int tag => throw new InvalidOperationException($"Unknown Direction wire tag: {tag}"),
            };

        internal static void WireEncodeTo(this Direction value, WireWriter wire) =>
            wire.WriteI32(value switch
            {
                Direction.North => 0,
                Direction.South => 1,
                Direction.East => 2,
                Direction.West => 3,
                _ => throw new InvalidOperationException($"Unknown Direction variant: {value}"),
            });
    }

    public static class DirectionMethods
    {

        public static Direction FromDegrees(double degrees)
        {
            return NativeMethods.DirectionFromDegrees(degrees);
        }

        public static uint Count()
        {
            return NativeMethods.DirectionCount();
        }

        public static Direction Opposite(this Direction self)
        {
            return NativeMethods.DirectionOpposite(self);
        }

        public static bool IsHorizontal(this Direction self)
        {
            return NativeMethods.DirectionIsHorizontal(self);
        }

        public static string Label(this Direction self)
        {
            FfiBuf _buf = NativeMethods.DirectionLabel(self);
            try
            {
                return new WireReader(_buf).ReadString();
            }
            finally
            {
                NativeMethods.FreeBuf(_buf);
            }
        }
    }
}
