1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use TokenStream;
/// Automatically wraps a struct with an `Inner` postfix in an `Arc`
///
/// This macro generates:
/// 1. A wrapper struct that contains `Arc<OriginalStructInner>`
/// 2. A `Clone` implementation for the wrapper
/// 3. A `Deref` implementation that derefs to the inner struct
/// 4. A `new` function that takes the inner struct and wraps it in Arc
///
/// # Example
///
/// ```ignore
/// use synapse_macros::arc_wrap;
///
/// #[arc_wrap]
/// pub struct MyService {
/// pub data: String,
/// pub count: u32,
/// }
///
/// // This generates:
/// // pub struct MyServiceInner { pub data: String, pub count: u32 }
/// // pub struct MyService(Arc<MyServiceInner>);
/// // impl Clone for MyService { ... }
/// // impl Deref for MyService { ... }
/// // impl MyService { pub fn new(inner: MyServiceInner) -> Self { ... } }
/// ```
/// Derive macro for RPC errors
///
/// Generates `From<YourError> for ServiceError` and `IntoServiceError` implementations.
///
/// Use `#[rpc(status = "...", code = ...)]` attributes on variants to customize
/// the RPC status and error code.
///
/// # Example
///
/// ```ignore
/// use synapse_macros::RpcError;
///
/// #[derive(Debug, thiserror::Error, RpcError)]
/// pub enum UserError {
/// #[error("user not found: {0}")]
/// #[rpc(status = "Error", code = 404)]
/// NotFound(String),
///
/// #[error("invalid email format")]
/// #[rpc(status = "InvalidRequest", code = 400)]
/// InvalidEmail,
///
/// #[error("user is banned")]
/// #[rpc(code = 3001)] // defaults to Error status
/// Banned,
/// }
/// ```
///
/// # Available statuses
///
/// - `Ok` - Success
/// - `Error` - Generic error (default)
/// - `Timeout` - Request timed out
/// - `InterfaceNotFound` - Interface not found
/// - `MethodNotFound` - Method not found
/// - `Unavailable` - Service unavailable
/// - `InvalidRequest` - Bad request
/// - `UnsupportedVersion` - Unsupported protocol version
/// - `ServiceDraining` - Service is draining
/// - `ServiceFrozen` - Service is frozen
/// - `MessageTooLarge` - Message too large