Initial public release of Warp.

Repo-Sync-Origin: warpdotdev/warp-internal@12af1d983b
This commit is contained in:
David Stern
2026-04-28 08:43:33 -05:00
commit 0dbd3d567a
4982 changed files with 1431549 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
#[cfg_attr(macos, path = "mac.rs")]
#[cfg_attr(windows, path = "windows.rs")]
#[cfg_attr(noop, path = "noop.rs")]
mod imp;
use std::{
pin::Pin,
task::{Context, Poll},
};
use pin_project::pin_project;
pub use imp::Guard;
/// Returns a guard that prevents the system from going to sleep while the guard is held.
///
/// Callers should provide a description of the reason for preventing sleep. Depending on
/// platform, this may appear in logs, so write it as though it may be user-visible, e.g.:
/// "Agent Mode request in-progress".
pub fn prevent_sleep(reason: &'static str) -> Guard {
imp::prevent_sleep(reason)
}
/// A simple wrapper around a stream that optionally prevents the system from going to sleep
/// while the stream is being polled.
#[pin_project]
pub struct Stream<S> {
#[pin]
inner: S,
guard: Option<Guard>,
}
impl<S> Stream<S> {
/// Wraps the provided stream, maintaining the provided sleep guard as long as the stream is
/// being polled.
pub fn wrap(inner: S, guard: Option<Guard>) -> Self {
Self { inner, guard }
}
}
impl<S: futures::stream::Stream> futures::stream::Stream for Stream<S> {
type Item = S::Item;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.project().inner.poll_next(cx)
}
}