Clean up conversions between raw/managed/ref types

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • bson-3.0.0
    • Affects Version/s: None
    • Component/s: None
    • Rust Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Right now, how to convert between these various types is kind of a mess:

      RawBsonRef to RawBson => RawBsonRef::to_raw_bson
      RawBsonRef to Bson => impl TryFrom
      RawBson to RawBsonRef =>  RawBson::as_raw_bson_ref
      RawBson to Bson => impl TryFrom
      Bson to RawBson => impl TryFrom

      RawDocument to RawDocumentBuf => RawDocument::to_raw_document_buf and impl ToOwned
      RawDocument to Document => impl TryFrom
      RawDocumentBuf to RawDocument => impl Deref
      RawDocumentBuf to Document => impl TryFrom and RawDocumentBuf::to_document
      Document to RawDocumentBuf => impl TryFrom and RawDocumentBuf:from_document

      RawArray to RawArrayBuf => RawArray::to_raw_array_buf and impl ToOwned
      RawArray to Array => impl TryFrom
      RawArrayBuf to RawArray => impl Deref
      RawArrayBuf to Array => none (can go via RawArray)
      Array to RawArrayBuf => none

      I propose we standardize around the standard conversion traits rather than having a mix of traits and explicit functions. The exception to this is RawBson::as_raw_bson_ref, which IMO should exist by analogy to as_ref.

              Assignee:
              Abraham Egnor
              Reporter:
              Abraham Egnor
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: