pub struct BindingCall { /* private fields */ }Expand description
BindingCall represents a single JS → Rust callback invocation.
When JavaScript calls an exposed function (registered via expose_function
or expose_binding), the server sends a bindingCall event on the
BrowserContext channel containing the GUID of a freshly created BindingCall
object. The Rust handler must call either resolve
or reject to unblock the JS caller.
See: https://playwright.dev/docs/api/class-browsercontext#browser-context-expose-function
Implementations§
Source§impl BindingCall
impl BindingCall
Sourcepub fn new(
parent: Arc<dyn ChannelOwner>,
type_name: String,
guid: Arc<str>,
initializer: Value,
) -> Result<Self>
pub fn new( parent: Arc<dyn ChannelOwner>, type_name: String, guid: Arc<str>, initializer: Value, ) -> Result<Self>
Creates a new BindingCall from protocol initialization.
Called by the object factory when the server sends a __create__
message for a BindingCall object.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the name of the binding that was called.
Matches the name argument passed to expose_function / expose_binding.
Sourcepub fn args(&self) -> &Value
pub fn args(&self) -> &Value
Returns the raw serialized arguments sent by the JS caller.
This is the args array from the initializer, in Playwright’s
type-tagged protocol format (e.g. [{"n": 3}, {"n": 7}]).
Sourcepub async fn resolve(&self, result: Value) -> Result<()>
pub async fn resolve(&self, result: Value) -> Result<()>
Resolves the binding call with a result value.
Sends the resolve RPC back to the Playwright server so the
JS await of the exposed function resolves with result.
§Arguments
result- The value to return to the JavaScript caller, already serialized in Playwright’sserialize_argumentformat ({"value": ..., "handles": []}).
§Errors
Returns error if communication with the browser process fails.
Trait Implementations§
Source§impl Clone for BindingCall
impl Clone for BindingCall
Source§fn clone(&self) -> BindingCall
fn clone(&self) -> BindingCall
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more