@@ -575,8 +575,8 @@ pub(crate) struct MysqlOpts {
575575 /// Database name (defaults to `None`).
576576 db_name : Option < String > ,
577577
578- /// TCP keep alive timeout in milliseconds (defaults to `None`).
579- tcp_keepalive : Option < u32 > ,
578+ /// TCP keep alive timeout (defaults to `None`).
579+ tcp_keepalive : Option < Duration > ,
580580
581581 /// Whether to enable `TCP_NODELAY` (defaults to `true`).
582582 ///
@@ -804,7 +804,7 @@ impl Opts {
804804 /// assert_eq!(opts.tcp_keepalive(), Some(10_000));
805805 /// # Ok(()) }
806806 /// ```
807- pub fn tcp_keepalive ( & self ) -> Option < u32 > {
807+ pub fn tcp_keepalive ( & self ) -> Option < Duration > {
808808 self . inner . mysql_opts . tcp_keepalive
809809 }
810810
@@ -1353,8 +1353,8 @@ impl OptsBuilder {
13531353 }
13541354
13551355 /// Defines `tcp_keepalive` option. See [`Opts::tcp_keepalive`].
1356- pub fn tcp_keepalive < T : Into < u32 > > ( mut self , tcp_keepalive : Option < T > ) -> Self {
1357- self . opts . tcp_keepalive = tcp_keepalive. map ( Into :: into ) ;
1356+ pub fn tcp_keepalive ( mut self , tcp_keepalive : Option < Duration > ) -> Self {
1357+ self . opts . tcp_keepalive = tcp_keepalive;
13581358 self
13591359 }
13601360
@@ -1773,7 +1773,7 @@ fn mysqlopts_from_url(url: &Url) -> std::result::Result<MysqlOpts, UrlError> {
17731773 }
17741774 } else if key == "tcp_keepalive" {
17751775 match u32:: from_str ( & value) {
1776- Ok ( value) => opts. tcp_keepalive = Some ( value) ,
1776+ Ok ( value) => opts. tcp_keepalive = Some ( Duration :: from_millis ( value. into ( ) ) ) ,
17771777 _ => {
17781778 return Err ( UrlError :: InvalidParamValue {
17791779 param : "tcp_keepalive_ms" . into ( ) ,
0 commit comments