using AIStudio.Tools.Rust;
namespace AIStudio.Tools.DocumentSegments;
///
/// A kind of document whose text a model works on segment by segment, while everything else of the
/// document stays as it is, e.g., Word documents or Markdown files.
///
public interface IDocumentSegmentFormat
{
///
/// The kind of file this format reads and writes, which the save dialog offers.
///
public FileTypeFilter FileType { get; }
///
/// What of a document of this kind stays as it is, for the user, e.g., "Code and formulas stay as they are."
///
public string LimitsNotice { get; }
///
/// The size of the largest text of a document this format reads on this computer, in bytes, see TextSizeOf.
///
///
/// A format holds the text of a document in memory, as bytes, as text, and as the tree of its parser or the DOM of
/// the Open XML SDK, and takes many times its size while reading and writing it. Its limit keeps that within the
/// memory of this computer, see DocumentMemoryBudget, and a document with a larger text is refused with a
/// DocumentTooLargeException.
///
public long MaxTextSize { get; }
///
/// Measures the text of a document, which the format holds in memory: the whole file of a document which is text
/// itself, and the XML of an Office document without its pictures and videos.
///
/// The document.
/// The size in bytes.
public long TextSizeOf(string path);
///
/// Reads the segments of a document, in the order of the document.
///
/// The document.
/// Cancels the reading.
/// The segments, including those without letters.
public Task> ReadAsync(string path, CancellationToken token);
///
/// Writes a copy of a document with the new texts of its segments.
///
///
/// The format reads the source again and writes nothing when the results do not cover one of its
/// segments. It writes only into the target, which the user chose, and leaves the source as it is.
///
/// The document the segments were read from.
/// The new document, which the user chose.
/// What became of the segments.
/// The IETF tag of the language of the new texts, e.g., "de-DE", which the format notes where the document records languages; empty when the language is unknown or unchanged.
/// Where the format reports what goes wrong on the way, e.g., a temporary file which cannot be removed.
/// Cancels the writing.
public Task WriteAsync(string sourcePath, string targetPath, SegmentResults results, string languageTag, ILogger logger, CancellationToken token);
}