Skip to content

Commit

Permalink
Annotate appendTags and insertTags functions with @discardableResult
Browse files Browse the repository at this point in the history
…on NostrEventBuilding protocol and expose getter for tags list (#185)
  • Loading branch information
tyiu authored Oct 18, 2024
1 parent ce5b584 commit d8ada06
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sources/NostrSDK/Events/NostrEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,22 @@ public protocol NostrEventBuilding {
/// The type of ``NostrEvent`` that this builder constructs.
associatedtype EventType: NostrEvent

/// List of ``Tag``s.
var tags: [Tag] { get }

/// Sets the unix timestamp in seconds of when the event is created.
func createdAt(_ createdAt: Int64?) -> Self

/// Appends the given list of tags to the end of the existing tags list.
/// - Parameters:
/// - tags: The list of ``Tag`` objects.
@discardableResult
func appendTags(_ tags: Tag...) -> Self

/// Appends the given list of tags to the end of the existing tags list.
/// - Parameters:
/// - tags: The list of ``Tag`` objects.
@discardableResult
func appendTags(contentsOf tags: [Tag]) -> Self

/// Inserts the given list of tags at a given index of the list.
Expand All @@ -225,6 +230,7 @@ public protocol NostrEventBuilding {
/// - index: The index of the existing list to insert the new tags into.
/// The tags are appended to the end of the list if the index is `nil`.
/// Must be a valid index of the existing tags list.
@discardableResult
func insertTags(_ tags: Tag..., at index: Int) -> Self

/// Inserts the given list of tags at a given index of the list.
Expand All @@ -233,6 +239,7 @@ public protocol NostrEventBuilding {
/// - index: The index of the existing list to insert the new tags into.
/// The tags are appended to the end of the list if the index is `nil`.
/// Must be a valid index of the existing tags list.
@discardableResult
func insertTags(contentsOf tags: [Tag], at index: Int) -> Self

/// Arbitrary string.
Expand Down Expand Up @@ -308,7 +315,6 @@ public extension NostrEvent {
@discardableResult
public final func appendTags(_ tags: Tag...) -> Self {
appendTags(contentsOf: tags)
return self
}

@discardableResult
Expand All @@ -320,7 +326,6 @@ public extension NostrEvent {
@discardableResult
public final func insertTags(_ tags: Tag..., at index: Int) -> Self {
insertTags(contentsOf: tags, at: index)
return self
}

@discardableResult
Expand Down

0 comments on commit d8ada06

Please sign in to comment.