Skip to content

Commit 9f6bd0d

Browse files
committed
chore(concurrency): make CasbinError & nested enums Sendable; constrain InternalApi generic; wrap FileAdapter handlers; mark Config Sendable\n\n- Adds Sendable to error enums\n- Constrains afterOperatePolicy generic T: Sendable\n- Wraps Util.* handlers in explicit @sendable closures\n- Marks Config as Sendable\n\nThis consolidates sendability fixes into one PR to address Swift 6 warnings.
1 parent 2a43b7e commit 9f6bd0d

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

Sources/Casbin/APi/InternalApi.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ extension CoreApi {
7474
}
7575

7676

77-
private func afterOperatePolicy<T>(sec:String,oped:Bool,d:EventData,t:T) -> EventLoopFuture<T> {
77+
private func afterOperatePolicy<T: Sendable>(sec:String,oped:Bool,d:EventData,t:T) -> EventLoopFuture<T> {
7878
if oped {
7979
emit(e: Event.PolicyChange, d: d)
8080
emit(e: Event.ClearCache, d: EventData.ClearCache)
@@ -88,4 +88,3 @@ extension CoreApi {
8888
return eventLoopGroup.next().makeSucceededFuture(t)
8989
}
9090
}
91-

Sources/Casbin/CasbinError.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
import Foundation
16-
public enum CasbinError:Error,LocalizedError,CustomStringConvertible {
16+
public enum CasbinError: Error, LocalizedError, CustomStringConvertible, Sendable {
1717
public var description: String {
1818
switch self {
1919
case .RBAC_ERROR(let e):
@@ -36,7 +36,7 @@ public enum CasbinError:Error,LocalizedError,CustomStringConvertible {
3636
case OtherErrorMessage(String)
3737
case IoError(String)
3838

39-
public enum MatchError: CustomStringConvertible {
39+
public enum MatchError: CustomStringConvertible, Sendable {
4040
public var description: String {
4141
switch self {
4242

@@ -51,7 +51,7 @@ public enum CasbinError:Error,LocalizedError,CustomStringConvertible {
5151
case MatchFuntionArgsNotString
5252
}
5353

54-
public enum RbacError: CustomStringConvertible {
54+
public enum RbacError: CustomStringConvertible, Sendable {
5555
public var description: String {
5656
switch self {
5757

@@ -75,7 +75,7 @@ public enum CasbinError:Error,LocalizedError,CustomStringConvertible {
7575
case InvalidFieldVaulesParameter
7676
}
7777

78-
public enum ModelError:CustomStringConvertible {
78+
public enum ModelError: CustomStringConvertible, Sendable {
7979
public var description: String {
8080
switch self {
8181

0 commit comments

Comments
 (0)