wechat_minapp/new_type/
mod.rs1mod non_query_page_path;
4mod page_path;
5mod scene;
6
7use crate::error::Error;
8pub use non_query_page_path::NonQueryPagePath;
9pub use page_path::PagePath;
10pub use scene::{SceneString, ValidationSceneError};
11use std::fmt;
12
13#[derive(Debug, Clone, PartialEq)]
15pub enum PagePathError {
16 StartsWithSlash,
18 ContainsParams,
20 InvalidFormat,
22 InvalidLength,
24 ReservedParameter,
26 Empty,
28}
29
30impl std::error::Error for PagePathError {}
31
32impl From<url::ParseError> for PagePathError {
33 fn from(_value: url::ParseError) -> Self {
34 PagePathError::InvalidFormat
35 }
36}
37
38impl From<Error> for PagePathError {
39 fn from(_value: Error) -> Self {
40 PagePathError::InvalidFormat
41 }
42}
43impl fmt::Display for PagePathError {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 match self {
46 PagePathError::StartsWithSlash => write!(f, "页面路径不能以斜杠开头"),
47 PagePathError::ContainsParams => {
48 write!(f, "页面路径不能携带参数,参数请放在scene字段里")
49 }
50 PagePathError::InvalidFormat => write!(f, "页面路径格式不正确"),
51 PagePathError::InvalidLength => write!(f, "页面路径最大长度 1024 个字符"),
52 PagePathError::Empty => write!(f, "页面路径不能为空"),
53 PagePathError::ReservedParameter => {
54 write!(f, "页面路径包含系统保留参数 'scancode_time'")
55 }
56 }
57 }
58}