pub struct Phone { /* private fields */ }Expand description
The phone’s parts (spec 3.3 §5.4): build it with Phone::builder, serve it with
router, and start its wake-ups with Phone::start_push.
§Example
use std::sync::Arc;
use adk_core::{InMemoryApprovalStore, StoreApprovalService};
use adk_kernel::pairing::{InMemoryDeviceStore, Pairing};
use adk_session::InMemorySessionService;
use adk_surface::mobile::{Phone, PushDoorbell, PushKey};
use adk_surface::{LocalSource, SurfaceEngine};
let doorbell = Arc::new(PushDoorbell::new());
let approvals = Arc::new(
StoreApprovalService::new(Arc::new(InMemoryApprovalStore::new())).with_notifier(doorbell.clone()),
);
let source = LocalSource::builder("adk-rust")
.sessions(Arc::new(InMemorySessionService::new()))
.approvals(approvals.clone())
.build()?;
let engine = SurfaceEngine::builder(Arc::new(source)).stops_need("operator").build();
let pairing = Pairing::new(Arc::new(InMemoryDeviceStore::new()));
let phone = Phone::builder(engine, pairing)
.home_url("https://home.example.ts.net")
.push_key(PushKey::generate()?)
.doorbell(doorbell)
.approvals(approvals)
.build()?;
let routes = adk_surface::mobile::router(phone.clone());Implementations§
Source§impl Phone
impl Phone
Sourcepub fn builder(engine: SurfaceEngine, pairing: Pairing) -> PhoneBuilder
pub fn builder(engine: SurfaceEngine, pairing: Pairing) -> PhoneBuilder
A builder over engine and the kernel’s pairing.
Sourcepub fn doorbell(&self) -> Arc<PushDoorbell> ⓘ
pub fn doorbell(&self) -> Arc<PushDoorbell> ⓘ
The doorbell to add to the approval service.
Sourcepub fn start_push(&self) -> Result<JoinHandle<()>, MobileError>
pub fn start_push(&self) -> Result<JoinHandle<()>, MobileError>
Starts sending wake-ups (spec 3.3 §5.4): one for each decision the doorbell hears about, held through quiet time; one per phone at the start and when quiet time ends. The task stops when it is aborted or the doorbell is dropped.
§Errors
Returns MobileError::NeedsHomeUrl without a home URL, and an invalid-input error
without an approval service to read waiting decisions from.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Phone
impl !UnwindSafe for Phone
impl Forget for Phone
impl Freeze for Phone
impl Move for Phone
impl Send for Phone
impl Sync for Phone
impl Unpin for Phone
impl UnsafeUnpin for Phone
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§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> ⓘ
Converts
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> ⓘ
Converts
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