pub struct DeviceAuthView {
id: Id,
rect: Rectangle,
children: Vec<Box<dyn View>>,
view_id: ViewId,
cancelled: Arc<AtomicBool>,
}Expand description
Displays the GitHub device auth flow user code and polls for authorization.
Shows two lines of text:
- The verification URL (
github.com/login/device) - The user code to enter (e.g.
WDJB-MJHT)
A Cancel button stops the background polling thread and closes the view.
A background thread polls GitHub at the required interval. When the user
authorizes, Event::Github with GithubEvent::DeviceAuthComplete is sent through the hub.
Fields§
§id: Id§rect: Rectangle§children: Vec<Box<dyn View>>§view_id: ViewId§cancelled: Arc<AtomicBool>Shared flag — set to true to stop the polling thread.
Implementations§
Source§impl DeviceAuthView
impl DeviceAuthView
Sourcepub fn new(hub: &Hub, context: &mut Context) -> Self
pub fn new(hub: &Hub, context: &mut Context) -> Self
Creates a new device auth view and immediately starts polling.
Initiates the GitHub device auth flow, builds the UI with the user code, and spawns a background thread to poll for authorization.
§Arguments
hub- Event hub used to send auth result eventscontext- Application context for font metrics
§Errors
If the device flow initiation fails, sends Event::Github with GithubEvent::DeviceAuthError
immediately and returns a view with an error message.
Sourcefn initiate_and_spawn(
hub: &Hub,
cancelled: Arc<AtomicBool>,
) -> Result<(String, String), GithubError>
fn initiate_and_spawn( hub: &Hub, cancelled: Arc<AtomicBool>, ) -> Result<(String, String), GithubError>
Initiates the device flow and spawns the polling thread.
Returns (verification_uri, user_code) on success so the caller can
display them. The polling thread checks cancelled before each poll
and exits cleanly when it is set.
Sourcefn cancel_polling(&self)
fn cancel_polling(&self)
Stops the background polling thread.
Trait Implementations§
Source§impl View for DeviceAuthView
impl View for DeviceAuthView
Source§fn handle_event(
&mut self,
evt: &Event,
_hub: &Hub,
bus: &mut Bus,
_rq: &mut RenderQueue,
_context: &mut Context,
) -> bool
fn handle_event( &mut self, evt: &Event, _hub: &Hub, bus: &mut Bus, _rq: &mut RenderQueue, _context: &mut Context, ) -> bool
Handles events for the device auth view.
Captures all tap gestures within the view to prevent parent views from handling them (which would close the modal). The user must use the Cancel button to close this view and return to the parent.
fn render( &self, _fb: &mut dyn Framebuffer, _rect: Rectangle, _fonts: &mut Fonts, )
fn rect(&self) -> &Rectangle
fn rect_mut(&mut self) -> &mut Rectangle
fn children(&self) -> &Vec<Box<dyn View>>
fn children_mut(&mut self) -> &mut Vec<Box<dyn View>>
fn id(&self) -> Id
fn view_id(&self) -> Option<ViewId>
fn resize( &mut self, _rect: Rectangle, _hub: &Hub, _rq: &mut RenderQueue, _context: &mut Context, )
fn render_rect(&self, _rect: &Rectangle) -> Rectangle
fn child(&self, index: usize) -> &dyn View
fn child_mut(&mut self, index: usize) -> &mut dyn View
fn len(&self) -> usize
fn might_skip(&self, _evt: &Event) -> bool
fn might_rotate(&self) -> bool
fn is_background(&self) -> bool
Auto Trait Implementations§
impl Freeze for DeviceAuthView
impl !RefUnwindSafe for DeviceAuthView
impl !Send for DeviceAuthView
impl !Sync for DeviceAuthView
impl Unpin for DeviceAuthView
impl !UnwindSafe for DeviceAuthView
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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