pub struct Pglite { /* private fields */ }Expand description
Primary entry point for interacting with the embedded Postgres runtime.
Implementations§
Source§impl Pglite
impl Pglite
Sourcepub fn builder() -> PgliteBuilder
pub fn builder() -> PgliteBuilder
Create a builder for opening persistent or temporary PGlite databases.
Sourcepub fn open(root: impl AsRef<Path>) -> Result<Self>
pub fn open(root: impl AsRef<Path>) -> Result<Self>
Open a persistent PGlite database rooted at root, installing and initializing it if needed.
Sourcepub fn open_app(app_id: (&str, &str, &str)) -> Result<Self>
pub fn open_app(app_id: (&str, &str, &str)) -> Result<Self>
Open a persistent PGlite database under the platform data directory for app_id.
Sourcepub fn temporary() -> Result<Self>
pub fn temporary() -> Result<Self>
Create an ephemeral PGlite database whose files are removed when the instance is dropped.
Sourcepub fn query(
&mut self,
sql: &str,
params: &[Value],
options: Option<&QueryOptions>,
) -> Result<Results>
pub fn query( &mut self, sql: &str, params: &[Value], options: Option<&QueryOptions>, ) -> Result<Results>
Execute a SQL query using the extended protocol.
Sourcepub fn exec(
&mut self,
sql: &str,
options: Option<&QueryOptions>,
) -> Result<Vec<Results>>
pub fn exec( &mut self, sql: &str, options: Option<&QueryOptions>, ) -> Result<Vec<Results>>
Execute a simple SQL statement that may contain multiple commands.
Sourcepub fn listen<F>(
&mut self,
channel: &str,
callback: F,
) -> Result<ListenerHandle>
pub fn listen<F>( &mut self, channel: &str, callback: F, ) -> Result<ListenerHandle>
Register a listener for LISTEN channel. Returns a handle that can be used to unlisten.
Sourcepub fn unlisten(&mut self, handle: ListenerHandle) -> Result<()>
pub fn unlisten(&mut self, handle: ListenerHandle) -> Result<()>
Remove a listener corresponding to the provided handle.
Sourcepub fn unlisten_channel(&mut self, channel: &str) -> Result<()>
pub fn unlisten_channel(&mut self, channel: &str) -> Result<()>
Remove all listeners for the specified channel.
Sourcepub fn on_notification<F>(&mut self, callback: F) -> GlobalListenerHandle
pub fn on_notification<F>(&mut self, callback: F) -> GlobalListenerHandle
Register a global notification callback.
Sourcepub fn off_notification(&mut self, handle: GlobalListenerHandle)
pub fn off_notification(&mut self, handle: GlobalListenerHandle)
Deregister a previously registered global notification callback.
Sourcepub fn describe_query(
&mut self,
sql: &str,
options: Option<&QueryOptions>,
) -> Result<DescribeQueryResult>
pub fn describe_query( &mut self, sql: &str, options: Option<&QueryOptions>, ) -> Result<DescribeQueryResult>
Describe the parameter and result metadata for a SQL query.
Sourcepub fn transaction<F, T>(&mut self, callback: F) -> Result<T>
pub fn transaction<F, T>(&mut self, callback: F) -> Result<T>
Run a closure within an SQL transaction (BEGIN .. COMMIT/ROLLBACK).
Sourcepub fn sync_to_fs(&mut self) -> Result<()>
pub fn sync_to_fs(&mut self) -> Result<()>
Flush runtime writes to the underlying filesystem. Currently a no-op on the host.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pglite
impl !RefUnwindSafe for Pglite
impl Send for Pglite
impl !Sync for Pglite
impl Unpin for Pglite
impl UnsafeUnpin for Pglite
impl !UnwindSafe for Pglite
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more