// Copyright 2009-2022 Josh Close
// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
// https://github.com/JoshClose/CsvHelper
using System;
using System.Collections;
using System.IO;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading;
namespace CsvHelper
{
///
/// Defines methods used to write to a CSV file.
///
public interface IWriter : IWriterRow, IDisposable
#if !NET45 && !NET47 && !NETSTANDARD2_0
, IAsyncDisposable
#endif
{
///
/// Flushes the internal buffer to the then
/// flushes the .
///
void Flush();
///
/// Flushes the internal buffer to the then
/// flushes the .
///
Task FlushAsync();
///
/// Ends writing of the current record and starts a new record.
/// This flushes the buffer to the but
/// does not flush the .
///
void NextRecord();
///
/// Ends writing of the current record and starts a new record.
/// This flushes the buffer to the but
/// does not flush the .
///
Task NextRecordAsync();
///
/// Writes the list of records to the CSV file.
///
/// The records to write.
void WriteRecords(IEnumerable records);
///
/// Writes the list of records to the CSV file.
///
/// Record type.
/// The records to write.
void WriteRecords(IEnumerable records);
///
/// Writes the list of records to the CSV file.
///
/// The records to write.
/// The cancellation token to stop the writing.
Task WriteRecordsAsync(IEnumerable records, CancellationToken cancellationToken = default);
///
/// Writes the list of records to the CSV file.
///
/// Record type.
/// The records to write.
/// The cancellation token to stop the writing.
Task WriteRecordsAsync(IEnumerable records, CancellationToken cancellationToken = default);
#if !NET45
///
/// Writes the list of records to the CSV file.
///
/// Record type.
/// The records to write.
/// The cancellation token to stop the writing.
Task WriteRecordsAsync(IAsyncEnumerable records, CancellationToken cancellationToken = default);
#endif
}
}