pub trait BoxOps: Object {
Show 27 methods
// Required methods
fn be_absorbed(&self, document: &mut Document) -> Result<Vec<Node>>;
fn get_string(&self) -> Result<Cow<'_, str>>;
fn with_properties<R, FnR>(&self, caller: FnR) -> R
where FnR: FnOnce(&HashMap<Stored>) -> R;
fn get_font(&self) -> Result<Option<Rc<Font>>>;
fn compute_size(
&self,
options: HashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)>;
// Provided methods
fn unlist(&self) -> Vec<Digested> { ... }
fn unlist_ref(&self) -> Vec<Cow<'_, Digested>> { ... }
fn be_absorbed_mut(&mut self, _document: &mut Document) -> Result<Vec<Node>> { ... }
fn get_tokens(&self) -> Option<&Tokens> { ... }
fn get_properties(&self) -> &HashMap<Stored> { ... }
fn get_properties_mut(&mut self) -> &mut HashMap<Stored> { ... }
fn set_property<T: Into<Stored>>(&mut self, key: &str, value: T) { ... }
fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>> { ... }
fn get_property_string(&self, key: &str) -> String { ... }
fn get_property_mut(&mut self, key: &str) -> Option<&mut Stored> { ... }
fn has_property(&self, key: &str) -> bool { ... }
fn get_property_bool(&self, key: &str) -> bool { ... }
fn get_body(&self) -> Result<Option<Digested>> { ... }
fn set_font(&mut self, _font: Rc<Font>) { ... }
fn set_width<T: Into<Stored>>(&mut self, width: T) { ... }
fn get_width(
&self,
options: Option<HashMap<Stored>>,
) -> Result<Option<RegisterValue>> { ... }
fn set_height<T: Into<Stored>>(&mut self, width: T) { ... }
fn get_height(&self) -> Option<RegisterValue> { ... }
fn set_depth<T: Into<Stored>>(&mut self, width: T) { ... }
fn get_depth(&self) -> Option<RegisterValue> { ... }
fn get_size(
&mut self,
options: Option<HashMap<Stored>>,
) -> Result<(Dimension, Dimension, Dimension, Dimension, Dimension, Dimension)> { ... }
fn compute_size_and_cache(
&mut self,
options: HashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)> { ... }
}Expand description
Common operations for Box-like (digested) data
Required Methods§
Sourcefn be_absorbed(&self, document: &mut Document) -> Result<Vec<Node>>
fn be_absorbed(&self, document: &mut Document) -> Result<Vec<Node>>
absorb the current object into the Document XML - returning the corresponding nodes
Sourcefn get_string(&self) -> Result<Cow<'_, str>>
fn get_string(&self) -> Result<Cow<'_, str>>
build a string representation of the underlying digested data
Sourcefn with_properties<R, FnR>(&self, caller: FnR) -> R
fn with_properties<R, FnR>(&self, caller: FnR) -> R
execute a function using this object’s named properties
Provided Methods§
Sourcefn unlist(&self) -> Vec<Digested>
fn unlist(&self) -> Vec<Digested>
If composite, unwrap into the contained digested objects (or return self)
fn unlist_ref(&self) -> Vec<Cow<'_, Digested>>
Sourcefn be_absorbed_mut(&mut self, _document: &mut Document) -> Result<Vec<Node>>
fn be_absorbed_mut(&mut self, _document: &mut Document) -> Result<Vec<Node>>
be_absorbed but with allowed side-effects on the carrier (for Alignment only)
Sourcefn get_tokens(&self) -> Option<&Tokens>
fn get_tokens(&self) -> Option<&Tokens>
get the underlying tokens (preceding digestion)
Sourcefn get_properties(&self) -> &HashMap<Stored>
fn get_properties(&self) -> &HashMap<Stored>
deprecated: get the map of named properties. This can not be usable as long as we have any
data behind a RefCell wrapper.
Use with_properties instead.
Sourcefn get_properties_mut(&mut self) -> &mut HashMap<Stored>
fn get_properties_mut(&mut self) -> &mut HashMap<Stored>
get a mutable reference to the map of named properties
Sourcefn set_property<T: Into<Stored>>(&mut self, key: &str, value: T)
fn set_property<T: Into<Stored>>(&mut self, key: &str, value: T)
set a named property (allows all Stored types for values)
Sourcefn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>
fn get_property(&self, key: &str) -> Option<Cow<'_, Stored>>
get a single named property (with special “isSpace” check)
fn get_property_string(&self, key: &str) -> String
Sourcefn get_property_mut(&mut self, key: &str) -> Option<&mut Stored>
fn get_property_mut(&mut self, key: &str) -> Option<&mut Stored>
get a mutable reference to a single named property (does NOT have the “isSpace” check)
Sourcefn has_property(&self, key: &str) -> bool
fn has_property(&self, key: &str) -> bool
checks if a property key has been set
Sourcefn get_property_bool(&self, key: &str) -> bool
fn get_property_bool(&self, key: &str) -> bool
obtains a boolean property value (false unless Stored::Bool)
Sourcefn get_body(&self) -> Result<Option<Digested>>
fn get_body(&self) -> Result<Option<Digested>>
obtains the “body” of a digested object which captured it
Sourcefn get_width(
&self,
options: Option<HashMap<Stored>>,
) -> Result<Option<RegisterValue>>
fn get_width( &self, options: Option<HashMap<Stored>>, ) -> Result<Option<RegisterValue>>
gets the “width” property value, if any
Sourcefn set_height<T: Into<Stored>>(&mut self, width: T)
fn set_height<T: Into<Stored>>(&mut self, width: T)
sets a “height” property value, for sizing
Sourcefn get_height(&self) -> Option<RegisterValue>
fn get_height(&self) -> Option<RegisterValue>
gets the “height” property value, if any. Checks “height”, then “cached_height”, then computes from font if needed.
Sourcefn get_depth(&self) -> Option<RegisterValue>
fn get_depth(&self) -> Option<RegisterValue>
gets the “depth” property value, if any. Checks “depth”, then “cached_depth”, then computes from font if needed.
Sourcefn get_size(
&mut self,
options: Option<HashMap<Stored>>,
) -> Result<(Dimension, Dimension, Dimension, Dimension, Dimension, Dimension)>
fn get_size( &mut self, options: Option<HashMap<Stored>>, ) -> Result<(Dimension, Dimension, Dimension, Dimension, Dimension, Dimension)>
gets the box size as a triple of (width, height, depth)
the generic implementation is immutable and will recompute the size on each call
see Digested::get_size for a variant with interior mutability which caches the box size
Sourcefn compute_size_and_cache(
&mut self,
options: HashMap<Stored>,
) -> Result<(Dimension, Dimension, Dimension)>
fn compute_size_and_cache( &mut self, options: HashMap<Stored>, ) -> Result<(Dimension, Dimension, Dimension)>
computes and caches (via named properties) the size of a box-like object.
Perl #2798 (S5, padding slice): after computing the size, add any requested
pad{top,bottom,left,right} to the computed dimensions. This is the SAFE
part of computeSizeStore — additive and inert until the app layer sets a
pad* property (display math \abovedisplayskip/\belowdisplayskip,
\overline/\underline 2pt, items/equations). The riskier requested-vs-
computed merge + full-spec bypass + isEmpty are deliberately NOT included
here — a mechanical port of those regressed (Rust boxes don’t use
width/height/depth uniformly as “requested box size”); see SYNC_STATUS U2.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".