pub struct PromptAssembly { /* private fields */ }Expand description
The prompt, mid-assembly, as one hook is allowed to see and change it.
Implementations§
Source§impl PromptAssembly
impl PromptAssembly
pub fn new(blocks: Vec<PromptBlock>, authority: Authority) -> Self
pub fn blocks(&self) -> &[PromptBlock]
pub fn into_blocks(self) -> Vec<PromptBlock>
Sourcepub fn position(&self, name: &str) -> Option<usize>
pub fn position(&self, name: &str) -> Option<usize>
Position of the block named name, if it is present.
Sourcepub fn push(&mut self, block: PromptBlock)
pub fn push(&mut self, block: PromptBlock)
Add a block at the end. Always permitted — adding cannot unsay anything that was already said.
Sourcepub fn insert_after(&mut self, name: &str, block: PromptBlock)
pub fn insert_after(&mut self, name: &str, block: PromptBlock)
Add a block directly after name, or at the end if there is no such
block. Always permitted, for the same reason as push:
nothing that was there stops being there.
Sourcepub fn modify(&mut self, name: &str, content: String) -> Result<bool, Denied>
pub fn modify(&mut self, name: &str, content: String) -> Result<bool, Denied>
Rewrite a block’s content. Requires modify.
Ok(false) means there was no such block — a hook targeting something
optional should not have to care whether this session has it.
Auto Trait Implementations§
impl Forget for PromptAssembly
impl Freeze for PromptAssembly
impl Move for PromptAssembly
impl RefUnwindSafe for PromptAssembly
impl Send for PromptAssembly
impl Sync for PromptAssembly
impl Unpin for PromptAssembly
impl UnsafeUnpin for PromptAssembly
impl UnwindSafe for PromptAssembly
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