@@ -750,11 +750,10 @@ impl Socket {
750
750
751
751
/// Receive a `String` from the socket.
752
752
///
753
- /// If the received message is not valid UTF-8, it is returned as the original
754
- /// Vec in the `Err` part of the inner result.
755
- pub fn recv_string ( & self , flags : i32 ) -> Result < result:: Result < String , Vec < u8 > > > {
756
- self . recv_bytes ( flags)
757
- . map ( |bytes| String :: from_utf8 ( bytes) . map_err ( FromUtf8Error :: into_bytes) )
753
+ /// If the received message is not valid UTF-8, a [`FromUtf8Error`] is returned and the original
754
+ /// bytes can be retrieved via [`FromUtf8Error::into_bytes()`].
755
+ pub fn recv_string ( & self , flags : i32 ) -> Result < result:: Result < String , FromUtf8Error > > {
756
+ self . recv_bytes ( flags) . map ( String :: from_utf8)
758
757
}
759
758
760
759
/// Receive a multipart message from the socket.
@@ -885,7 +884,7 @@ impl Socket {
885
884
sockopt:: get_bytes ( self . sock , zmq_sys:: ZMQ_ROUTING_ID as c_int , 255 )
886
885
}
887
886
888
- pub fn get_socks_proxy ( & self ) -> Result < result:: Result < String , Vec < u8 > > > {
887
+ pub fn get_socks_proxy ( & self ) -> Result < result:: Result < String , FromUtf8Error > > {
889
888
// 255 = longest allowable domain name is 253 so this should
890
889
// be a reasonable size.
891
890
sockopt:: get_string ( self . sock , zmq_sys:: ZMQ_SOCKS_PROXY as c_int , 255 , true )
@@ -901,17 +900,17 @@ impl Socket {
901
900
} )
902
901
}
903
902
904
- pub fn get_plain_username ( & self ) -> Result < result:: Result < String , Vec < u8 > > > {
903
+ pub fn get_plain_username ( & self ) -> Result < result:: Result < String , FromUtf8Error > > {
905
904
// 255 = arbitrary size
906
905
sockopt:: get_string ( self . sock , zmq_sys:: ZMQ_PLAIN_USERNAME as c_int , 255 , true )
907
906
}
908
907
909
- pub fn get_plain_password ( & self ) -> Result < result:: Result < String , Vec < u8 > > > {
908
+ pub fn get_plain_password ( & self ) -> Result < result:: Result < String , FromUtf8Error > > {
910
909
// 256 = arbitrary size based on std crypto key size
911
910
sockopt:: get_string ( self . sock , zmq_sys:: ZMQ_PLAIN_PASSWORD as c_int , 256 , true )
912
911
}
913
912
914
- pub fn get_zap_domain ( & self ) -> Result < result:: Result < String , Vec < u8 > > > {
913
+ pub fn get_zap_domain ( & self ) -> Result < result:: Result < String , FromUtf8Error > > {
915
914
// 255 = arbitrary size
916
915
sockopt:: get_string ( self . sock , zmq_sys:: ZMQ_ZAP_DOMAIN as c_int , 255 , true )
917
916
}
@@ -924,7 +923,7 @@ impl Socket {
924
923
/// used with the wildcard address (`"*"`), in the address
925
924
/// returned, the wildcard will be expanded into the any address
926
925
/// (i.e. `0.0.0.0` with IPv4).
927
- pub fn get_last_endpoint ( & self ) -> Result < result:: Result < String , Vec < u8 > > > {
926
+ pub fn get_last_endpoint ( & self ) -> Result < result:: Result < String , FromUtf8Error > > {
928
927
// 256 + 9 + 1 = maximum inproc name size (= 256) + "inproc://".len() (= 9), plus null byte
929
928
sockopt:: get_string (
930
929
self . sock ,
@@ -962,12 +961,12 @@ impl Socket {
962
961
sockopt:: get_bytes ( self . sock , zmq_sys:: ZMQ_CURVE_SERVERKEY as c_int , 32 )
963
962
}
964
963
965
- pub fn get_gssapi_principal ( & self ) -> Result < result:: Result < String , Vec < u8 > > > {
964
+ pub fn get_gssapi_principal ( & self ) -> Result < result:: Result < String , FromUtf8Error > > {
966
965
// 260 = best guess of max length based on docs.
967
966
sockopt:: get_string ( self . sock , zmq_sys:: ZMQ_GSSAPI_PRINCIPAL as c_int , 260 , true )
968
967
}
969
968
970
- pub fn get_gssapi_service_principal ( & self ) -> Result < result:: Result < String , Vec < u8 > > > {
969
+ pub fn get_gssapi_service_principal ( & self ) -> Result < result:: Result < String , FromUtf8Error > > {
971
970
// 260 = best guess of max length based on docs.
972
971
sockopt:: get_string (
973
972
self . sock ,
0 commit comments