Statv
Stats 🔗
Bases: Generic[T]
状态属性
Attributes:
Source code in statv/statv.py
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
__init__ 🔗
__init__(
id: str,
*,
default: T = Ellipsis,
default_factory: Callable[[], T] | None = None,
validator: StatsValidator[T] | None = None
) -> None
Parameters:
-
id
(
str
) –状态标识
-
default
(
T
) –默认值
-
default_factory
(
Callable[[], T]
) –默认值工厂函数
-
validator
(
StatsValidator[T]
) –状态校验器
Source code in statv/statv.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
validator 🔗
validator(validator: StatsValidator[T])
设置状态校验器
Parameters:
-
validator
(
StatsValidator[T]
) –状态校验器
Source code in statv/statv.py
111 112 113 114 115 116 117 118 119 120 |
|
StatsValidator 🔗
Bases: Protocol[T]
状态校验器协议
Source code in statv/statv.py
16 17 18 19 20 21 22 23 24 25 26 |
|
__call__ 🔗
__call__(stats: Stats[T], past: T, current: T) -> T
Parameters:
-
stats
(
Stats[T]
) –状态属性
-
past
(
T
) –过去状态
-
current
(
T
) –当前状态
Source code in statv/statv.py
19 20 21 22 23 24 25 26 |
|
Statv 🔗
状态对象
Source code in statv/statv.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
__init__ 🔗
__init__(*, init_stats: dict[str, Any] | None = None)
Parameters:
Source code in statv/statv.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
available
property
🔗
available() -> bool
可用性
Source code in statv/statv.py
178 179 180 181 |
|
defined_stats
classmethod
🔗
defined_stats() -> list[Stats]
on_update 🔗
on_update(
stats: Stats[T],
) -> Callable[[UpdateMonitor[Self, T]], UpdateMonitor[Self, T]]
注册更新监视器
Parameters:
-
stats
(
Stats[T]
) –监视的状态属性
Returns:
-
Callable[[UpdateMonitor[Self, T]], UpdateMonitor[Self, T]]
–接受
UpdateMonitor[Self, T]
并将其原样返回的装饰器
Source code in statv/statv.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
update_multi 🔗
update_multi(mapping: dict[Stats[Any], Any]) -> None
更新多个状态
Parameters:
Source code in statv/statv.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
wait_for_available
async
🔗
wait_for_available()
等待状态对象可用
Source code in statv/statv.py
219 220 221 222 |
|
wait_for_unavailable
async
🔗
wait_for_unavailable()
等待状态对象不可用
Source code in statv/statv.py
224 225 226 227 |
|
wait_for_update
async
🔗
wait_for_update() -> Self
等待状态更新
Returns:
-
Self
–状态对象本身
Source code in statv/statv.py
206 207 208 209 210 211 212 213 214 215 216 217 |
|
UpdateMonitor 🔗
Bases: Protocol[Statv_T, T]
更新监视器协议
Source code in statv/statv.py
29 30 31 32 33 34 35 36 37 38 39 40 |
|
__call__ 🔗
__call__(statv: Statv_T, stats: Stats[T], past: T, current: T) -> Any
Parameters:
Source code in statv/statv.py
32 33 34 35 36 37 38 39 40 |
|