Skip to content

Commit

Permalink
Draft IWritableVault
Browse files Browse the repository at this point in the history
  • Loading branch information
SakuraIsayeki committed Mar 27, 2024
1 parent d2431d4 commit 25d5acc
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Nodsoft.MoltenObsidian/Vault/IWritableVault.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace Nodsoft.MoltenObsidian.Vault;

/// <summary>
/// Specifies an editable Obisidian vault, which is a collection of folders and Markdown files.
/// </summary>
/// <remarks>
/// This interface is storage-agnostic, and should be able to be implemented using any storage mechanism.
/// </remarks>
/// <seealso cref="IVault"/>
public interface IWritableVault : IVault
{
/// <summary>
/// Creates a new folder with the specified path.
/// </summary>
/// <param name="path">The path of the folder to create.</param>
/// <returns>A task that holds the newly created folder as its result.</returns>
/// <exception cref="ArgumentException">Thrown if the specified path is invalid.</exception>
/// <exception cref="InvalidOperationException">Thrown if a folder with the specified path already exists.</exception>
/// <exception cref="IOException">Thrown if an I/O error occurs.</exception>
ValueTask<IVaultFolder> CreateFolderAsync(string path);

/// <summary>
/// Creates a new file with the specified path.
/// </summary>
/// <remarks>
/// If the file's path hits a missing folder, the folder will be created.
/// </remarks>
/// <param name="path">The path of the file to create.</param>
/// <param name="content">The content of the file to create.</param>
/// <returns>A task that holds the newly created file as its result.</returns>
/// <exception cref="ArgumentException">Thrown if the specified path is invalid.</exception>
/// <exception cref="InvalidOperationException">Thrown if a file with the specified path already exists.</exception>
/// <exception cref="IOException">Thrown if an I/O error occurs.</exception>
ValueTask<IVaultFile> CreateFileAsync(string path, ReadOnlySpan<byte> content);

/// <summary>
/// Creates a new note with the specified path.
/// </summary>
/// <remarks>
/// If the note's path hits a missing folder, the folder will be created.
/// </remarks>
/// <param name="path">The path of the note to create.</param>
/// <param name="content">The content of the note to create.</param>
/// <returns>A task that holds the newly created note as its result.</returns>
/// <exception cref="ArgumentException">Thrown if the specified path is invalid.</exception>
/// <exception cref="InvalidOperationException">Thrown if a note with the specified path already exists.</exception>
/// <exception cref="IOException">Thrown if an I/O error occurs.</exception>
/// <seealso cref="CreateFileAsync(string, ReadOnlySpan{byte})"/>
ValueTask<IVaultNote> CreateNoteAsync(string path, ReadOnlySpan<char> content);
}

0 comments on commit 25d5acc

Please sign in to comment.