Module lock_ext

Module lock_ext 

Source
Expand description

Extended lock support for parking_lot and tokio.

This module provides wrappers and extension traits for third-party lock types, enabling them to work with the lock-aware query system.

§Features

  • parking_lot Support: High-performance RwLock and Mutex wrappers
  • tokio Support: Async RwLock support for async applications
  • Extension Traits: Direct .lock_query() and .lock_join() support

§Example (parking_lot)

use rust_queries_core::lock_ext::{ParkingLotRwLockWrapper, ParkingLotQueryExt};
use std::collections::HashMap;
use parking_lot::RwLock;

let mut products: HashMap<String, ParkingLotRwLockWrapper<Product>> = HashMap::new();
products.insert("p1".to_string(), ParkingLotRwLockWrapper::new(Product {
    id: 1,
    price: 999.99,
}));

// Direct method call!
let expensive = products
    .lock_query()
    .where_(Product::price(), |&p| p > 500.0)
    .all();

§Example (tokio)

use rust_queries_core::lock_ext::{TokioRwLockWrapper, TokioLockQueryExt};
use std::collections::HashMap;

async fn query_products(products: &HashMap<String, TokioRwLockWrapper<Product>>) {
    let expensive = products
        .lock_query()  // Direct method call!
        .where_(Product::price(), |&p| p > 500.0)
        .all();
}