// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CommunityToolkit.Common.Helpers;
///
/// Service interface used to store data in a directory/file-system via files and folders.
///
/// This interface is meant to help abstract file storage operations across platforms in a library,
/// but the actual behavior will be up to the implementer. Such as, we don't provide a sense of a current directory,
/// so an implementor should consider using full paths to support any file operations. Otherwise, a "directory aware"
/// implementation could be achieved with a current directory field and traversal functions, in which case relative paths would be applicable.
///
public interface IFileStorageHelper
{
///
/// Retrieves an object from a file.
///
/// Type of object retrieved.
/// Path to the file that contains the object.
/// Default value of the object.
/// Waiting task until completion with the object in the file.
Task ReadFileAsync(string filePath, T? @default = default);
///
/// Retrieves the listings for a folder and the item types.
///
/// The path to the target folder.
/// A list of item types and names in the target folder.
Task> ReadFolderAsync(string folderPath);
///
/// Saves an object inside a file.
///
/// Type of object saved.
/// Path to the file that will contain the object.
/// Object to save.
/// Waiting task until completion.
Task CreateFileAsync(string filePath, T value);
///
/// Ensure a folder exists at the folder path specified.
///
/// The path and name of the target folder.
/// Waiting task until completion.
Task CreateFolderAsync(string folderPath);
///
/// Deletes a file or folder item.
///
/// The path to the item for deletion.
/// Waiting task until completion.
Task TryDeleteItemAsync(string itemPath);
///
/// Rename an item.
///
/// The path to the target item.
/// The new nam for the target item.
/// Waiting task until completion.
Task TryRenameItemAsync(string itemPath, string newName);
}