Get information about a view. Returns the view's metadata including its Merkle state and change count. # Arguments `name` - The name of the view to query # Returns A `ViewInfo` struct with the view's metadata, or an error if the view doesn't exist.
(&self, name: &str)
| 497 | /// A `ViewInfo` struct with the view's metadata, or an error if the view |
| 498 | /// doesn't exist. |
| 499 | pub fn get_view_info(&self, name: &str) -> Result<ViewInfo, RepositoryError> { |
| 500 | let txn = self |
| 501 | .pristine |
| 502 | .read_txn() |
| 503 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 504 | |
| 505 | let view = txn |
| 506 | .get_view(name) |
| 507 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 508 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 509 | name: name.to_string(), |
| 510 | })?; |
| 511 | |
| 512 | // Resolve parent name if the view has a parent |
| 513 | let parent_name = if let Some(parent_id) = view.parent { |
| 514 | txn.get_view_by_id(parent_id) |
| 515 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 516 | .map(|p| p.name) |
| 517 | } else { |
| 518 | None |
| 519 | }; |
| 520 | |
| 521 | Ok(ViewInfo { |
| 522 | name: view.name.clone(), |
| 523 | state: view.state, |
| 524 | change_count: view.change_count, |
| 525 | scope: view.kind, |
| 526 | parent_name, |
| 527 | }) |
| 528 | } |
| 529 | } |