@@ -3,8 +3,8 @@ use pyo3::prelude::*;
33use pyo3:: types:: { PyBytes , PyNone , PyString } ;
44use restate_sdk_shared_core:: {
55 CallHandle , CoreVM , DoProgressResponse , Error , Header , IdentityVerifier , Input , NonEmptyValue ,
6- NotificationHandle , ResponseHead , RetryPolicy , RunExitResult , SuspendedOrVMError ,
7- TakeOutputResult , Target , TerminalFailure , VMOptions , Value , CANCEL_NOTIFICATION_HANDLE , VM ,
6+ NotificationHandle , ResponseHead , RetryPolicy , RunExitResult , TakeOutputResult , Target ,
7+ TerminalFailure , VMOptions , Value , CANCEL_NOTIFICATION_HANDLE , VM ,
88} ;
99use std:: time:: { Duration , SystemTime } ;
1010
@@ -330,10 +330,10 @@ impl PyVM {
330330 let py = self_. py ( ) ;
331331
332332 match res {
333- Err ( SuspendedOrVMError :: VM ( e) ) => Err ( e. into ( ) ) ,
334- Err ( SuspendedOrVMError :: Suspended ( _) ) => {
333+ Err ( e) if e. is_suspended_error ( ) => {
335334 Ok ( PySuspended . into_py ( py) . into_bound ( py) . into_any ( ) )
336335 }
336+ Err ( e) => Err ( e. into ( ) ) ,
337337 Ok ( DoProgressResponse :: AnyCompleted ) => Ok ( PyDoProgressAnyCompleted
338338 . into_py ( py)
339339 . into_bound ( py)
@@ -352,10 +352,9 @@ impl PyVM {
352352 . into_py ( py)
353353 . into_bound ( py)
354354 . into_any ( ) ) ,
355- Ok ( DoProgressResponse :: WaitingPendingRun ) => Ok ( PyDoWaitForPendingRun
356- . into_py ( py)
357- . into_bound ( py)
358- . into_any ( ) ) ,
355+ Ok ( DoProgressResponse :: WaitingPendingRun ) => {
356+ Ok ( PyDoWaitForPendingRun . into_py ( py) . into_bound ( py) . into_any ( ) )
357+ }
359358 }
360359 }
361360
@@ -377,10 +376,10 @@ impl PyVM {
377376 let py = self_. py ( ) ;
378377
379378 match res {
380- Err ( SuspendedOrVMError :: VM ( e) ) => Err ( e. into ( ) ) ,
381- Err ( SuspendedOrVMError :: Suspended ( _) ) => {
379+ Err ( e) if e. is_suspended_error ( ) => {
382380 Ok ( PySuspended . into_py ( py) . into_bound ( py) . into_any ( ) )
383381 }
382+ Err ( e) => Err ( e. into ( ) ) ,
384383 Ok ( None ) => Ok ( PyNone :: get_bound ( py) . to_owned ( ) . into_any ( ) ) ,
385384 Ok ( Some ( Value :: Void ) ) => Ok ( PyVoid . into_py ( py) . into_bound ( py) . into_any ( ) ) ,
386385 Ok ( Some ( Value :: Success ( b) ) ) => Ok ( PyBytes :: new_bound ( py, & b) . into_any ( ) ) ,
@@ -451,7 +450,11 @@ impl PyVM {
451450 . expect ( "Duration since unix epoch cannot fail" ) ;
452451 self_
453452 . vm
454- . sys_sleep ( String :: default ( ) , now + Duration :: from_millis ( millis) , Some ( now) )
453+ . sys_sleep (
454+ String :: default ( ) ,
455+ now + Duration :: from_millis ( millis) ,
456+ Some ( now) ,
457+ )
455458 . map ( Into :: into)
456459 . map_err ( Into :: into)
457460 }
@@ -494,7 +497,7 @@ impl PyVM {
494497 buffer : & Bound < ' _ , PyBytes > ,
495498 key : Option < String > ,
496499 delay : Option < u64 > ,
497- idempotency_key : Option < String > ,
500+ idempotency_key : Option < String > ,
498501 headers : Option < Vec < PyHeader > > ,
499502 ) -> Result < PyNotificationHandle , PyVMError > {
500503 self_
@@ -615,11 +618,11 @@ impl PyVM {
615618 self_. vm . sys_run ( name) . map ( Into :: into) . map_err ( Into :: into)
616619 }
617620
618- fn sys_cancel (
619- mut self_ : PyRefMut < ' _ , Self > ,
620- invocation_id : String ,
621- ) -> Result < ( ) , PyVMError > {
622- self_ . vm . sys_cancel_invocation ( invocation_id ) . map_err ( Into :: into)
621+ fn sys_cancel ( mut self_ : PyRefMut < ' _ , Self > , invocation_id : String ) -> Result < ( ) , PyVMError > {
622+ self_
623+ . vm
624+ . sys_cancel_invocation ( invocation_id )
625+ . map_err ( Into :: into)
623626 }
624627
625628 fn propose_run_completion_success (
@@ -699,7 +702,9 @@ impl PyVM {
699702 ) -> Result < PyNotificationHandle , PyVMError > {
700703 self_
701704 . vm
702- . sys_attach_invocation ( restate_sdk_shared_core:: AttachInvocationTarget :: InvocationId ( invocation_id) )
705+ . sys_attach_invocation (
706+ restate_sdk_shared_core:: AttachInvocationTarget :: InvocationId ( invocation_id) ,
707+ )
703708 . map ( Into :: into)
704709 . map_err ( Into :: into)
705710 }
0 commit comments