-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// FastlyDevice.swift | ||
// | ||
// | ||
// Created by Andrew Barba on 3/19/24. | ||
// | ||
|
||
import ComputeRuntime | ||
|
||
extension Fastly { | ||
public struct Device: Sendable { | ||
|
||
public struct DeviceLookup: Codable, Sendable { | ||
public let name: String? | ||
public let brand: String? | ||
public let model: String? | ||
public let hardwareType: String? | ||
public let isDesktop: Bool? | ||
public let isGameConsole: Bool? | ||
public let isMediaPlayer: Bool? | ||
public let isMobile: Bool? | ||
public let isSmartTV: Bool? | ||
public let isTablet: Bool? | ||
public let isTouchscreen: Bool? | ||
} | ||
|
||
public static func lookup(userAgent: String) throws -> DeviceLookup { | ||
return try wasiDecode(maxBufferLength: maxIpLookupLength) { | ||
fastly_device__device_detection_lookup(userAgent, userAgent.utf8.count, $0, $1, &$2) | ||
} | ||
} | ||
|
||
private init() {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters