// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
namespace Regorus
{
///
/// Policy source length limits enforced when loading policy files.
///
public readonly struct PolicyLengthConfig
{
///
/// Initializes a new instance of the struct.
///
/// Maximum column width per line. Must be non-zero.
/// Maximum policy file size in bytes. Must be non-zero.
/// Maximum number of lines per policy file. Must be non-zero.
/// Thrown when any parameter is zero.
public PolicyLengthConfig(uint maxCol, nuint maxFileBytes, nuint maxLines)
{
if (maxCol == 0)
throw new ArgumentOutOfRangeException(nameof(maxCol), "Must be non-zero.");
if (maxFileBytes == 0)
throw new ArgumentOutOfRangeException(nameof(maxFileBytes), "Must be non-zero.");
if (maxLines == 0)
throw new ArgumentOutOfRangeException(nameof(maxLines), "Must be non-zero.");
MaxCol = maxCol;
MaxFileBytes = maxFileBytes;
MaxLines = maxLines;
}
/// Maximum column width per line (default: 1024).
public uint MaxCol { get; }
/// Maximum policy file size in bytes (default: 1 MiB).
public nuint MaxFileBytes { get; }
/// Maximum number of lines per policy file (default: 20000).
public nuint MaxLines { get; }
internal Regorus.Internal.RegorusPolicyLengthConfig ToNative()
{
return new Regorus.Internal.RegorusPolicyLengthConfig
{
max_col = MaxCol,
max_file_bytes = MaxFileBytes,
max_lines = MaxLines,
};
}
}
}