pub struct FieldRef<'a> { /* private fields */ }Expand description
Zero-copy field reference with cur_name overlay applied.
FieldRef provides a unified view of FieldStorage that respects
the cur_name override without cloning the underlying field.
§Performance
- Zero allocation: Only holds a reference to
FieldStorage(8 bytes) - Zero-copy access:
get_name(),get_value()etc. don’t clone - Lazy owned conversion: Cloning happens only when calling
to_owned()
§Examples
ⓘ
use std::sync::Arc;
use wp_model_core::model::{Field, FieldStorage, Value, DataType};
let field = Arc::new(Field::new(DataType::Chars, "original", Value::from("data")));
let mut storage = FieldStorage::from_shared(field);
storage.set_name("renamed");
let field_ref = storage.field_ref();
assert_eq!(field_ref.get_name(), "renamed");
assert_eq!(field_ref.get_value(), &Value::from("data"));Implementations§
Source§impl<'a> FieldRef<'a>
impl<'a> FieldRef<'a>
Sourcepub fn to_owned(self) -> Field<Value>
pub fn to_owned(self) -> Field<Value>
Convert to owned field with cur_name applied.
Clones the underlying field and applies the cur_name override if present.
Check if this field is shared (Arc-backed).
Sourcepub fn has_name_override(&self) -> bool
pub fn has_name_override(&self) -> bool
Check if cur_name override is active.
Get Arc reference count for debugging.
Returns Some(count) for Shared variant, None for Owned.
Trait Implementations§
impl<'a> Copy for FieldRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for FieldRef<'a>
impl<'a> RefUnwindSafe for FieldRef<'a>
impl<'a> Send for FieldRef<'a>
impl<'a> Sync for FieldRef<'a>
impl<'a> Unpin for FieldRef<'a>
impl<'a> UnwindSafe for FieldRef<'a>
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