use crate::widgets::Panel;
use std::any::Any;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct ItemContext {
pub index: usize,
pub data: Arc<dyn Any + Send + Sync>,
}
impl ItemContext {
#[deprecated(
note = "Use VirtualList::get_item_context_for_panel() instead. Global registry has been replaced with instance-owned registry for memory safety."
)]
pub fn get_for_panel(_panel: &Panel) -> Option<ItemContext> {
None
}
#[deprecated(note = "Use VirtualList::get_index_for_panel() instead")]
pub fn get_index_for_panel(_panel: &Panel) -> Option<usize> {
None
}
#[deprecated(note = "Use VirtualList::get_data_for_panel() instead")]
pub fn get_data_for_panel<T>(_panel: &Panel) -> Option<T>
where
T: Clone + 'static,
{
None
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_item_context_creation() {
let test_data = "test item data".to_string();
let context = ItemContext {
index: 42,
data: Arc::new(test_data),
};
assert_eq!(context.index, 42);
assert!(context.data.downcast_ref::<String>().is_some());
}
}