Meshtastic-Apple/Meshtastic/Enums/MessageDestination.swift

20 lines
402 B
Swift
Raw Normal View History

2024-02-17 13:26:09 -07:00
/// Helper abstraction for sharing functionality between channel and direct messaging.
enum MessageDestination {
case user(UserEntity)
case channel(ChannelEntity)
var userNum: Int64 {
switch self {
case let .user(user): return user.num
case .channel: return 0
}
}
var channelNum: Int32 {
switch self {
case .user: return 0
case let .channel(channel): return channel.index
}
}
}