| 215 | timestamp: "datetime.datetime | None"=None |
| 216 | ) -> "ScopeHandle", text_signature = "(name: str, scope_type: ScopeType, *, handle: ScopeHandle | None = None, attributes: ScopeAttributes | None = None, data: object | None = None, metadata: object | None = None, input: object | None = None, timestamp: datetime.datetime | None = None) -> ScopeHandle")] |
| 217 | fn push_scope( |
| 218 | name: &str, |
| 219 | scope_type: PyScopeType, |
| 220 | handle: Option<PyScopeHandle>, |
| 221 | attributes: Option<PyScopeAttributes>, |
| 222 | data: Option<&Bound<'_, PyAny>>, |
| 223 | metadata: Option<&Bound<'_, PyAny>>, |
| 224 | input: Option<&Bound<'_, PyAny>>, |
| 225 | timestamp: Option<&Bound<'_, PyAny>>, |
| 226 | ) -> PyResult<PyScopeHandle> { |
| 227 | let attrs = attributes |
| 228 | .map(|a| a.inner) |
| 229 | .unwrap_or(ScopeAttributes::empty()); |
| 230 | let d = opt_py_to_json(data)?; |
| 231 | let meta = opt_py_to_json(metadata)?; |
| 232 | let input = opt_py_to_json(input)?; |
| 233 | let timestamp = opt_py_to_timestamp(timestamp)?; |
| 234 | core_scope_api::push_scope( |
| 235 | core_scope_api::PushScopeParams::builder() |
| 236 | .name(name) |
| 237 | .scope_type(scope_type.into()) |
| 238 | .parent_opt(handle.as_ref().map(|h| &h.inner)) |
| 239 | .attributes(attrs) |
| 240 | .data_opt(d) |
| 241 | .metadata_opt(meta) |
| 242 | .input_opt(input) |
| 243 | .timestamp_opt(timestamp) |
| 244 | .build(), |
| 245 | ) |
| 246 | .map(PyScopeHandle::from) |
| 247 | .map_err(to_py_err) |
| 248 | } |
| 249 | |
| 250 | /// Remove a scope from the stack and emit an ``End`` event. |
| 251 | /// |