@@ -7,7 +7,7 @@ use crate::{
77 php_stream_wrapper_ops, php_unregister_url_stream_wrapper,
88 php_unregister_url_stream_wrapper_volatile, zend_string,
99 } ,
10- types:: ZendStr ,
10+ types:: ZendStr , error :: Error ,
1111} ;
1212
1313pub type StreamWrapper = php_stream_wrapper ;
@@ -41,20 +41,20 @@ impl StreamWrapper {
4141 }
4242 }
4343
44- pub fn register ( self , name : & str ) -> Result < Self , ( ) > {
44+ pub fn register ( self , name : & str ) -> Result < Self , Error > {
4545 // We have to convert it to a static so owned streamwrapper doesn't get dropped.
4646 let copy = Box :: new ( self ) ;
4747 let copy = Box :: leak ( copy) ;
48- let name = std:: ffi:: CString :: new ( name) . unwrap ( ) ;
48+ let name = std:: ffi:: CString :: new ( name) . expect ( "Could not create C string for name!" ) ;
4949 let result = unsafe { php_register_url_stream_wrapper ( name. as_ptr ( ) , copy) } ;
5050 if result == 0 {
5151 Ok ( * copy)
5252 } else {
53- Err ( ( ) )
53+ Err ( Error :: StreamWrapperRegistrationFailure )
5454 }
5555 }
5656
57- pub fn register_volatile ( self , name : & str ) -> Result < Self , ( ) > {
57+ pub fn register_volatile ( self , name : & str ) -> Result < Self , Error > {
5858 // We have to convert it to a static so owned streamwrapper doesn't get dropped.
5959 let copy = Box :: new ( self ) ;
6060 let copy = Box :: leak ( copy) ;
@@ -64,23 +64,23 @@ impl StreamWrapper {
6464 if result == 0 {
6565 Ok ( * copy)
6666 } else {
67- Err ( ( ) )
67+ Err ( Error :: StreamWrapperRegistrationFailure )
6868 }
6969 }
7070
71- pub fn unregister ( name : & str ) -> Result < ( ) , ( ) > {
72- let name = std:: ffi:: CString :: new ( name) . unwrap ( ) ;
71+ pub fn unregister ( name : & str ) -> Result < ( ) , Error > {
72+ let name = std:: ffi:: CString :: new ( name) . expect ( "Could not create C string for name!" ) ;
7373 match unsafe { php_unregister_url_stream_wrapper ( name. as_ptr ( ) ) } {
7474 0 => Ok ( ( ) ) ,
75- _ => Err ( ( ) ) ,
75+ _ => Err ( Error :: StreamWrapperUnregistrationFailure ) ,
7676 }
7777 }
7878
79- pub fn unregister_volatile ( name : & str ) -> Result < ( ) , ( ) > {
79+ pub fn unregister_volatile ( name : & str ) -> Result < ( ) , Error > {
8080 let name = ZendStr :: new ( name, false ) ;
8181 match unsafe { php_unregister_url_stream_wrapper_volatile ( ( * name) . as_ptr ( ) as _ ) } {
8282 0 => Ok ( ( ) ) ,
83- _ => Err ( ( ) ) ,
83+ _ => Err ( Error :: StreamWrapperUnregistrationFailure ) ,
8484 }
8585 }
8686
0 commit comments