StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | /// Determines if a user agent string indicates a mobile device. |
| 2 | pub fn is_mobile_user_agent(user_agent: &str) -> bool { |
| 3 | let ua_lower = user_agent.to_lowercase(); |
| 4 | |
| 5 | // iOS devices |
| 6 | if ua_lower.contains("iphone") || ua_lower.contains("ipad") || ua_lower.contains("ipod") { |
| 7 | return true; |
| 8 | } |
| 9 | |
| 10 | // Android devices (phones and tablets) |
| 11 | if ua_lower.contains("android") && !ua_lower.contains("windows") { |
| 12 | return true; |
| 13 | } |
| 14 | |
| 15 | // Other mobile platforms |
| 16 | if ua_lower.contains("webos") |
| 17 | || ua_lower.contains("blackberry") |
| 18 | || ua_lower.contains("bb10") // BlackBerry 10 devices |
| 19 | || ua_lower.contains("opera mini") |
| 20 | || ua_lower.contains("opera mobi") |
| 21 | || ua_lower.contains("iemobile") |
| 22 | || ua_lower.contains("windows phone") |
| 23 | { |
| 24 | return true; |
| 25 | } |
| 26 | |
| 27 | false |
| 28 | } |
| 29 | |
| 30 | #[cfg(test)] |
| 31 | #[path = "user_agent_tests.rs"] |
| 32 | mod user_agent_tests; |
| 33 |