pub struct OwnerOnly {
pub field: &'static str,
}Expand description
仅所有者可访问规则 — 自动追加 user_id = ? 条件
对应 Rails current_user scope / Spring Security @PostFilter。
§示例
use sz_orm_core::data_permission::{OwnerOnly, PermissionRule, PermissionContext};
let rule = OwnerOnly::new("user_id");
let ctx = PermissionContext::new().with_user_id(100);
let clause = rule.apply(&ctx).unwrap().unwrap();
assert_eq!(clause, "user_id = 100");Fields§
§field: &'static str所有者字段名(默认 “user_id”)
Implementations§
Trait Implementations§
Source§impl PermissionRule for OwnerOnly
impl PermissionRule for OwnerOnly
Auto Trait Implementations§
impl Freeze for OwnerOnly
impl RefUnwindSafe for OwnerOnly
impl Send for OwnerOnly
impl Sync for OwnerOnly
impl Unpin for OwnerOnly
impl UnsafeUnpin for OwnerOnly
impl UnwindSafe for OwnerOnly
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more