Skip to content

Commit

Permalink
RUMM-3151 docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshnj committed Jun 26, 2023
1 parent 5889552 commit 84beb87
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Datadog/DatadogCore/Storage/Writing/FileWriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ internal struct FileWriter: Writer {

// MARK: - Writing data

/// Encodes given value to JSON data and writes it to the file.
/// Encodes given encodable value and metadata, and writes it to the file.
/// If encryption is available, the data is encrypted before writing.
/// - Parameters:
/// - value: Encodable value to write.
/// - metadata: Encodable metadata to write.
func write<T: Encodable, M: Encodable>(value: T, metadata: M?) {
do {
let encodedValue = try encode(encodable: value, blockType: .event)
Expand Down
6 changes: 6 additions & 0 deletions Sources/Datadog/DatadogCore/Storage/Writing/Writer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ import Foundation

/// A type, writing data.
public protocol Writer {
/// Encodes given encodable value and metadata, and writes to the destination.
/// - Parameter value: Encodable value to write.
/// - Parameter metadata: Encodable metadata to write.
func write<T: Encodable, M: Encodable>(value: T, metadata: M?)
}

extension Writer {
/// Encodes given encodable value and writes to the destination.
/// Uses `write(value:metadata:)` with `nil` metadata.
/// - Parameter value: Encodable value to write.
public func write<T: Encodable>(value: T) {
let metadata: Data? = nil
write(value: value, metadata: metadata)
Expand Down

0 comments on commit 84beb87

Please sign in to comment.