//! `sail-rs`: the canonical, typed Sail SDK.
//!
//! [`Client`] is the entry point: a cheap-to-clone async handle that owns
//! configuration and transport (HTTP for lifecycle/app, gRPC for per-sailbox
//! exec and file streams). Bindings (the Python extension, the TypeScript
//! napi addon, and the CLI) are thin layers over it.
//!
//! As a library, this crate documents its whole public API and never writes to
//! the process streams or exits: callers decide how to surface output and
//! errors.
//!
//! The transport plumbing the bindings reach into lives under the hidden
//! [`internal`] module; it is not part of the public API and carries no
//! stability guarantee.
#![deny(missing_docs)]
#![deny(clippy::print_stdout, clippy::print_stderr, clippy::exit)]

pub mod app;
pub mod client;
pub mod config;
pub mod error;
pub mod exec;
pub mod guest;
pub mod image;
pub mod imagebuild;
pub mod sailbox;
pub mod shell;

pub use worker::{
    FileReader, FileWriter, Listener, WriteAbortHandle, WriteOptions, FILE_WRITE_CHUNK_BYTES,
};
// Hidden as a module: users hold its types via the re-exports above; the
// module itself is the workerproxy client, which is not a user surface.
#[doc(hidden)]
pub mod worker;

mod channels;
pub(crate) mod credentials;
pub(crate) mod http;
pub(crate) mod imagebuilder;
pub(crate) mod retry;
pub(crate) mod runtime;

pub use client::{Client, ClientBuilder};
pub use runtime::block_on;
pub use sailbox::object::Sailbox;

/// Re-export of the [`time`] crate, whose [`OffsetDateTime`](time::OffsetDateTime)
/// appears in public types (sailbox/volume timestamps). Re-exported so callers
/// name the same version the SDK was built against.
pub use time;

/// Generated protobuf/gRPC code for the sailbox services. The proto files are
/// the source of truth for these types, so the generated members carry no
/// hand-written docs and are exempt from our lint policy (the server stubs,
/// emitted only under `test-fakes`, are pure codegen we never hand-edit).
#[allow(missing_docs, clippy::all, clippy::pedantic)]
pub(crate) mod pb {
    pub mod workerproxy {
        pub mod v1 {
            tonic::include_proto!("workerproxy.v1");
        }
    }
    pub mod imagebuilder {
        pub mod v1 {
            tonic::include_proto!("imagebuilder.v1");
        }
    }
    pub mod image {
        pub mod v1 {
            tonic::include_proto!("image.v1");
        }
    }
}

/// Unstable, binding-only surface shared with the first-party CLI, Python, and
/// TypeScript (napi) bindings (and this crate's own integration tests): the raw
/// transport, the
/// credential store, and the generated protobuf code. Not part of the public
/// API and not covered by semantic versioning; do not depend on it from outside
/// this workspace.
#[doc(hidden)]
pub mod internal {
    pub mod credentials {
        pub use crate::credentials::*;
    }
    pub mod http {
        pub use crate::http::*;
    }
    pub mod pb {
        pub use crate::pb::*;
    }
    pub mod retry {
        pub use crate::retry::*;
    }

    pub use crate::runtime::runtime;
    pub use crate::sailbox::api::SailboxApi;
}
