pub async fn create_object(
parent: ParentOrConnection,
type_name: String,
guid: Arc<str>,
initializer: Value,
) -> Result<Arc<dyn ChannelOwner>>Expand description
Creates a protocol object from a __create__ message.
This function is the central object factory for the Playwright protocol. It maps type names from the server to Rust struct constructors.
§Arguments
parent- Either a parent ChannelOwner or the root Connectiontype_name- Protocol type name (e.g., “Playwright”, “BrowserType”)guid- Unique GUID assigned by the serverinitializer- JSON object with initial state
§Returns
An Arc<dyn ChannelOwner> pointing to the newly created object.
§Errors
Returns Error::ProtocolError if the type name is unknown or if
object construction fails.
§Example
ⓘ
let playwright_obj = create_object(
ParentOrConnection::Connection(connection),
"Playwright".to_string(),
Arc::from("playwright@1"),
json!({
"chromium": { "guid": "browserType@chromium" },
"firefox": { "guid": "browserType@firefox" },
"webkit": { "guid": "browserType@webkit" }
})
).await?;