app_store_server_library/models/
realtime_url_request.rs1use serde::{Deserialize, Serialize};
2
3const MAXIMUM_REALTIME_URL_LENGTH: usize = 256;
4
5#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
9pub struct RealtimeUrlRequest {
10 #[serde(rename = "realtimeURL")]
14 pub realtime_url: String,
15}
16
17impl RealtimeUrlRequest {
18 pub fn new(realtime_url: String) -> Result<Self, RealtimeUrlRequestValidationError> {
25 if realtime_url.chars().count() > MAXIMUM_REALTIME_URL_LENGTH {
26 return Err(RealtimeUrlRequestValidationError::RealtimeUrlTooLong);
27 }
28 Ok(Self { realtime_url })
29 }
30}
31
32#[derive(Debug, Clone, PartialEq, Eq)]
33pub enum RealtimeUrlRequestValidationError {
34 RealtimeUrlTooLong,
35}
36
37impl std::fmt::Display for RealtimeUrlRequestValidationError {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 match self {
40 RealtimeUrlRequestValidationError::RealtimeUrlTooLong => write!(
41 f,
42 "Realtime URL exceeds maximum length of {} characters",
43 MAXIMUM_REALTIME_URL_LENGTH
44 ),
45 }
46 }
47}
48
49impl std::error::Error for RealtimeUrlRequestValidationError {}