pub struct Root { /* private fields */ }Expand description
Root object for sending the initialize message to the Playwright server
This is an internal object not exposed to end users. It exists solely to
send the initialize message to the server during connection setup.
§Protocol Flow
When initialize() is called:
- Sends
initializemessage withsdkLanguage: "rust" - Server creates BrowserType objects (sends
__create__messages) - Server creates Playwright object (sends
__create__message) - Server responds with Playwright GUID:
{ "playwright": { "guid": "..." } } - All objects are now in the connection’s object registry
The Root object has an empty GUID ("") and is not registered in the
object registry. It’s discarded after initialization completes.
§Example
ⓘ
// Create root object with connection
let root = Root::new(connection.clone());
// Send initialize message to server
let response = root.initialize().await?;
// Verify Playwright GUID is returned
let playwright_guid = response["playwright"]["guid"]
.as_str()
.expect("Missing playwright.guid");
assert!(!playwright_guid.is_empty());
assert!(playwright_guid.contains("playwright"));
// Verify response contains BrowserType objects
assert!(response["playwright"].is_object());See:
Implementations§
Source§impl Root
impl Root
Sourcepub async fn initialize(&self) -> Result<Value>
pub async fn initialize(&self) -> Result<Value>
Send the initialize message to the Playwright server
This is a synchronous request that blocks until the server responds. By the time the response arrives, all protocol objects (Playwright, BrowserType, etc.) will have been created and registered.
§Returns
The server response containing the Playwright object GUID:
{
"playwright": {
"guid": "playwright"
}
}§Errors
Returns error if:
- Message send fails
- Server returns protocol error
- Connection is closed
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Root
impl !RefUnwindSafe for Root
impl Send for Root
impl Sync for Root
impl Unpin for Root
impl UnsafeUnpin for Root
impl !UnwindSafe for Root
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