using System;
using System.Diagnostics.CodeAnalysis;
namespace StardewModdingAPI.Web.Framework.Storage
{
/// The response for a get-file request.
internal class StoredFileInfo
{
/*********
** Accessors
*********/
/// Whether the file was successfully fetched.
[MemberNotNullWhen(true, nameof(StoredFileInfo.Content))]
public bool Success => this.Content != null && this.Error == null;
/// The fetched file content (if is true).
public string? Content { get; }
/// When the file will no longer be available.
public DateTimeOffset? Expiry { get; }
/// The error message if saving succeeded, but a non-blocking issue was encountered.
public string? Warning { get; }
/// The error message if saving failed.
public string? Error { get; }
/*********
** Public methods
*********/
/// Construct an instance.
/// The fetched file content (if is true).
/// When the file will no longer be available.
/// The error message if saving succeeded, but a non-blocking issue was encountered.
/// The error message if saving failed.
public StoredFileInfo(string? content, DateTimeOffset? expiry, string? warning = null, string? error = null)
{
this.Content = content;
this.Expiry = expiry;
this.Warning = warning;
this.Error = error;
}
/// Construct an instance.
/// The error message if saving failed.
public StoredFileInfo(string error)
{
this.Error = error;
}
}
}