XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESystem

【Rust】XFE系统,基于Rust和汇编

公开
关注 0 Fork 0 Star 0
UTF-8
namespace XFESystem.Documents;

public sealed record StoredDocument(ReadOnlyMemory<byte> Content, string Revision, bool IsReadOnly = false);

/// <summary>The OS filesystem adapter must enforce permissions, bounded reads and atomic compare-and-save.</summary>
public interface IDocumentStorage
{
    ValueTask<StoredDocument> ReadAsync(DocumentLocation location, int maximumBytes, CancellationToken cancellationToken);

    /// <summary>Replace the complete file atomically only if the revision still matches. Return its new revision.</summary>
    ValueTask<string> ReplaceAsync(DocumentLocation location, ReadOnlyMemory<byte> content,
        string expectedRevision, CancellationToken cancellationToken);
}

public sealed class DocumentConflictException(string message) : IOException(message);