(a) Warrant. If it appears from an affidavit filed by a party that a material witness in a pending case will not appear and testify, a magistrate may issue a warrant and fix bail with or without sureties in a sum considered adequate for the appearance of the witness.
(b) Hearing. If the witness is arrested on a warrant issued by the magistrate, the custodial authority shall notify the issuing magistrate before the end of the next business day. The magistrate shall provide a hearing to address bail and release conditions for the witness within three business days or, upon a showing of good cause, within a reasonable period of time. The witness shall be entitled to be represented by counsel. The court shall appoint counsel for an indigent witness if required to protect the rights of the witness.
(c) Examining witness. If necessary to secure the testimony of the witness, the magistrate may order that the witness remain in custody for a reasonable period of time so the witness can be examined and cross-examined before the magistrate in the presence of the defendant. The testimony shall be recorded. The witness shall then be released unless further detention is necessary to prevent a failure of justice.
(d) Use of testimony. If the witness is unavailable or fails to appear at any subsequent hearing or trial when ordered to do so, the recorded testimony may be used at the hearing or trial in lieu of the personal testimony of the witness.