Skip to content

Instantly share code, notes, and snippets.

@kinggoesgaming
Created September 1, 2018 23:07
Show Gist options
  • Save kinggoesgaming/8a7d703182075bf2b25792f63e1eef4e to your computer and use it in GitHub Desktop.
Save kinggoesgaming/8a7d703182075bf2b25792f63e1eef4e to your computer and use it in GitHub Desktop.

Hello, fellow Rustaceans,

As you know that uuid v0.7.0-beta was released last week and as the changes in the release are very significant, we saw it fit to write up a transition guide for previous users of uuid.

The major focus of this release was refactoring the codebase for maintainability and general use. In the process, we ended up with some breaking changes.

  • The minimum rust version was bumped from 1.18.0 to 1.22.0.
  • Items in the uuid prelude that have been refactored may need to adjustment accordingly.
  • 0.7.0 splits returning error into 2: uuid::parser::ParseError, for string errors and uuid::BytesError, for handling slices.

  • uuid::BytesError: Added. Provides error information on slices that processed for Uuid creation.
  • uuid::Hyphenated: Refactored to uuid::adapter::HyphenatedRef.
  • uuid::Simple: Refactored to uuid::adapter::SimpleRef.
  • uuid::NAMESPACE_DNS: Refactored to uuid::Uuid::NAMESPACE_DNS.
  • uuid::NAMESPACE_OID: Refactored to uuid::Uuid::NAMESPACE_OID.
  • uuid::NAMESPACE_URL: Refactored to uuid::Uuid::NAMESPACE_URL.
  • uuid::NAMESPACE_X500: Refactored to uuid::Uuid::NAMESPACE_X500.
  • uuid::ParseError: Refactored to uuid::parser::ParseError. The error now provides better context details for people who want to handle the error.
  • uuid::Urn: Refactored to uuid::adapter::UrnRef.
  • uuid::Uuid
    • as_bytes(&self) -> &[u8; 16]: Refactored to as_bytes(&self) -> &uuid::Bytes.
    • from_bytes(b: &[u8]) -> Result<uuid::Uuid, uuid::ParseError>: Refactored to from_slice(b: &[u8]) -> Result<uuid::Uuid, uuid::BytesError>.
    • from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8]) -> Result<uuid::Uuid, uuid::ParseError>: Refactored to from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8]) -> Result<uuid::Uuid, uuid::BytesError>.
    • from_random_bytes(b: [u8; 16]) -> Uuid: Refactored to from_random_bytes(bytes: uuid::Bytes) -> uuid::Uuid.
    • from_uuid_bytes(bytes: uuid::UuidBytes) -> uuid::Uuid: Refactored to from_bytes(bytes: uuid::Bytes) -> uuid::Uuid.
    • hyphenated(&self) -> uuid::Hyphenated: Refactored to to_hyphenated_ref(&self) -> uuid::adapter::HyphenatedRef
    • get_variant(&self) -> Option<uuid::UuidVariant>: Refactored to get_variant(&self) -> Option<uuid::Variant>.
    • get_version(&self) -> Option<uuid::UuidVersion>: Refactored to get_version(&self) -> Option<uuid::Version>.
    • new(v: uuid::UuidVersion) -> Option<uuid::Uuid>: Removed, as the result of the function was dependant on the feature gates that are active. Use any of the new_* functions or other constructors instead.
    • new_v1<T: uuid::UuidV1ClockSequence>(context: &T, seconds: u64, nsecs: u32, node: &[u8]) -> Result<uuid::Uuid, uuid::ParseError>: Refactored to new_v1<T>(context: &T, seconds: u64, nano_seconds: u32, node_id: &[u8]) -> Result<Self, BytesError> where T: uuid::v1::ClockSequence.
    • new_v3(namespace: &uuid::Uuid, name: &str) -> uuid::Uuid: Refactored to new_v3(namespace: &Uuid, name: &[u8]) -> Uuid
    • new_v5(namespace: &uuid::Uuid, name: &str) -> uuid::Uuid: Refactored to new_v5(namespace: &uuid::Uuid, name: &[u8]) -> uuid::Uuid
    • simple(&self) -> uuid::Simple: Refactored to to_simple_ref(&self) -> uuid::adapter::SimpleRef
    • urn(&self) -> uuid::Urn: Refactored to to_urn_ref(&self) -> uuid::UrnRef
  • uuid::UuidBytes: Renamed to uuid::Bytes.
  • uuid::UuidVariant: Renamed to uuid::Variant.
  • uuid::UuidVersion: Renamed to uuid::Version.
    • A new enum variant for Nil uuid.
  • uuid::UuidClockSequence: Refactored to uuid::v1::ClockSequence.
  • uuid::UuidV1Context: Refactored to uuid::v1::Context.
  • uuid::adapter::Hyphenated: Added. Adaptor over owned uuid::Uuids for hyphenated strings.
  • uuid::adapter::Simple: Added. Adaptor over owned uuid::Uuids for simple strings.
  • uuid::adapter::Urn: Added. Adaptor over owned uuid::Uuids for urn strings.
  • uuid::parser::Expected: Added. Provides context detail for uuid::parser::ParseError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment