Skip to main content

Rewrite

Trait Rewrite 

Source
pub trait Rewrite: Send + Sync {
    // Provided methods
    fn message(&self, at: &Place<'_>, message: &mut Message) -> bool { ... }
    fn aside(&self, at: &Place<'_>, aside: &mut Aside) -> bool { ... }
    fn value(&self, at: &Place<'_>, key: &str, value: &mut Value) -> bool { ... }
    fn text(&self, at: &Place<'_>, text: &mut String) -> bool { ... }
    fn file(&self, name: &str, bytes: &mut Vec<u8>) -> bool { ... }
}
Expand description

A change applied to every value a session keeps. Each hook edits its argument in place and returns whether it changed anything. Every hook defaults to no change, except file, which sends JSON files to value, JSON-lines files line by line, and other UTF-8 to text. A hook cannot add, drop or re-kind a record. Shared between owners, so it takes &self.

Provided Methods§

Source

fn message(&self, at: &Place<'_>, message: &mut Message) -> bool

A message of a push, a splice or a reset. Images are as stored: blob:<sha256>.<ext> in a push or a splice, inline in a reset; inline data put in a push or a splice is stored as a blob.

Source

fn aside(&self, at: &Place<'_>, aside: &mut Aside) -> bool

An aside put or replaced.

Source

fn value(&self, at: &Place<'_>, key: &str, value: &mut Value) -> bool

A saved value under key, or a JSON value of a file (key is its name). A value made null is removed.

Source

fn text(&self, at: &Place<'_>, text: &mut String) -> bool

Text of a file that is not JSON.

Source

fn file(&self, name: &str, bytes: &mut Vec<u8>) -> bool

The file name, whole.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F: Fn(&mut Message) -> bool + Send + Sync> Rewrite for Messages<F>

Source§

impl<F: Fn(&mut String) -> bool + Send + Sync> Rewrite for Strings<F>