pub struct HtmlAllocator { /* private fields */ }Implementations§
Source§impl HtmlAllocator
impl HtmlAllocator
Sourcepub fn new_with_metadb(
max_allocations: u32,
metadb: Option<&'static MetaDb>,
context: Context,
) -> Self
pub fn new_with_metadb( max_allocations: u32, metadb: Option<&'static MetaDb>, context: Context, ) -> Self
max_allocations: how many node (text, elements, empty nodes)
and attribute allocations in total are allowed before out of
memory errors are being returned for allocations (i.e. when
creating new elements, attributes, or pushing to an
AVec). metadb: if given, HTML structure is verified during
element allocation.
pub fn clear(&mut self)
pub fn regionid(&self) -> RegionId
pub fn assert_regionid(&self, rid: RegionId)
pub fn get_node<'a>(&'a self, id: AId<Node>) -> Option<&'a Node>
pub fn get_att<'a>( &'a self, id: AId<(KString, KString)>, ) -> Option<&'a (KString, KString)>
pub fn get_id<T: AllocatorType>(&self, id_bare: u32) -> Option<AId<T>>
pub fn new_vec<'a, T: AllocatorType>(&'a self) -> AVec<'a, T>
pub fn new_vec_with_capacity<'a, T: AllocatorType>( &'a self, capacity: u32, ) -> Result<AVec<'a, T>>
Sourcepub fn new_element(
&self,
meta: &'static ElementMeta,
attr: ASlice<(KString, KString)>,
body: ASlice<Node>,
) -> Result<AId<Node>>
pub fn new_element( &self, meta: &'static ElementMeta, attr: ASlice<(KString, KString)>, body: ASlice<Node>, ) -> Result<AId<Node>>
But also see element method for more comfort.
pub fn allocate_element(&self, elt: Element) -> Result<AId<Node>>
pub fn empty_node(&self) -> Result<AId<Node>>
pub fn new_attribute( &self, att: (KString, KString), ) -> Result<AId<(KString, KString)>>
pub fn attribute<K, V>(&self, key: K, val: V) -> Result<AId<(KString, KString)>>
pub fn preserialized(&self, val: SerHtmlFrag) -> Result<AId<Node>>
pub fn staticstr(&self, s: &'static str) -> Result<AId<Node>>
pub fn str(&self, s: &str) -> Result<AId<Node>>
Sourcepub fn text<T>(&self, s: T) -> Result<AId<Node>>
pub fn text<T>(&self, s: T) -> Result<AId<Node>>
Create a text node (i.e. put the given string into the allocator, return the id to it)
Sourcepub fn text_slice<T>(&self, s: T) -> Result<ASlice<Node>>
pub fn text_slice<T>(&self, s: T) -> Result<ASlice<Node>>
Like text but returns an ASlice containing the single text
node, for contexts that expect a slice (i.e. any number of
nodes).
pub fn string(&self, s: String) -> Result<AId<Node>>
pub fn opt_string(&self, s: Option<String>) -> Result<AId<Node>>
pub fn kstring(&self, s: KString) -> Result<AId<Node>>
Sourcepub fn element(
&self,
meta: &'static ElementMeta,
attr: impl ToASlice<(KString, KString)>,
body: impl ToASlice<Node>,
) -> Result<AId<Node>>
pub fn element( &self, meta: &'static ElementMeta, attr: impl ToASlice<(KString, KString)>, body: impl ToASlice<Node>, ) -> Result<AId<Node>>
Create an element from normal slices or arrays, for nice to use syntax.
pub fn empty_slice<T>(&self) -> ASlice<T>
Source§impl HtmlAllocator
impl HtmlAllocator
Sourcepub fn html_escape(&self, bytes: &[u8]) -> RefMut<'_, Vec<u8>>
pub fn html_escape(&self, bytes: &[u8]) -> RefMut<'_, Vec<u8>>
bytes must represent proper UTF-8,
e.g. string.as_bytes(). The resulting reference must be
dropped before calling html_escape again, or there will be a
panic.
pub fn print_html_fragment( &self, id_: AId<Node>, out: &mut impl Write, ) -> Result<()>
pub fn print_html_document( &self, id_: AId<Node>, out: &mut impl Write, ) -> Result<()>
pub fn to_html_string(&self, id: AId<Node>, want_doctype: bool) -> String
Sourcepub fn preserialize(&self, id: AId<Node>) -> Result<SerHtmlFrag>
pub fn preserialize(&self, id: AId<Node>) -> Result<SerHtmlFrag>
Returns an error if id doesn’t refer to an Element Node.