Struct PortablePtyBackend

Source
pub struct PortablePtyBackend { /* private fields */ }
Expand description

Native [portable_pty] backend with configurable output batching.

Construction performs no OS I/O; PtyBackend::spawn allocates the PTY and child. This backend does not sandbox programs, validate paths/environment, redact output/errors, or impose queue memory bounds.

§Examples

use ailloli_ui_terminal_pty::PortablePtyBackend;
let _backend = PortablePtyBackend::new();

Implementations§

Source§

impl PortablePtyBackend

Source

pub fn new() -> Self

Creates a backend with PtyBatchConfig::default.

§Examples
use ailloli_ui_terminal_pty::PortablePtyBackend;
let _backend = PortablePtyBackend::new();
Source

pub fn with_batch_config(batch_config: PtyBatchConfig) -> Self

Creates a backend that copies batch_config into every spawned session.

Values are stored without normalization. The batcher clamps a zero byte threshold to one, but the portable receive loop uses the timeout exactly. A zero timeout can therefore busy-spin whenever no raw chunk is ready. The byte threshold remains a flush trigger, not a hard event-size bound.

§Examples
use std::time::Duration;
use ailloli_ui_terminal_pty::{PortablePtyBackend, PtyBatchConfig};
let _backend = PortablePtyBackend::with_batch_config(PtyBatchConfig {
    max_bytes: 1024,
    flush_timeout: Duration::from_millis(4),
});

Trait Implementations§

Source§

impl Default for PortablePtyBackend

Source§

fn default() -> Self

Creates the same backend as Self::new.

§Examples
use ailloli_ui_terminal_pty::PortablePtyBackend;
let _backend = PortablePtyBackend::default();
Source§

impl PtyBackend for PortablePtyBackend

Source§

fn spawn(&self, config: PtySpawnConfig) -> Result<PtyHandle, PtyError>

Allocates a native PTY, spawns the configured child, and starts workers.

Rows/columns clamp to at least one. TERM is set from config.term, then ordered environment entries are applied; CWD is applied when present. With no program the platform default is selected and config.args is ignored. With a program, arguments are passed separately without shell interpolation by this layer.

Open/spawn/reader/writer setup errors map to PtyError::Spawn or PtyError::Io with backend strings. A failure after child spawn but before handle construction has no explicit kill path here and relies on dropped backend objects. The successful threads are detached and unjoined.

§Errors

Returns PtyError::Spawn if the native PTY cannot be allocated or the child cannot be started. Returns PtyError::Io if the spawned PTY’s reader or writer handle cannot be acquired.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.