mirror of
https://github.com/rwf2/Rocket.git
synced 2025-02-08 01:32:02 +00:00
Update 'uuid' to 1.0.
This commit is contained in:
parent
6bdd2f8186
commit
810f472524
@ -63,7 +63,7 @@ features = ["std"]
|
|||||||
|
|
||||||
[dependencies.uuid_]
|
[dependencies.uuid_]
|
||||||
package = "uuid"
|
package = "uuid"
|
||||||
version = "0.8"
|
version = "1"
|
||||||
optional = true
|
optional = true
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ uuid = ["uuid_", "rocket_http/uuid"]
|
|||||||
# Serialization dependencies.
|
# Serialization dependencies.
|
||||||
serde_json = { version = "1.0.26", optional = true }
|
serde_json = { version = "1.0.26", optional = true }
|
||||||
rmp-serde = { version = "1", optional = true }
|
rmp-serde = { version = "1", optional = true }
|
||||||
uuid_ = { package = "uuid", version = "0.8", optional = true, features = ["serde"] }
|
uuid_ = { package = "uuid", version = "1", optional = true, features = ["serde"] }
|
||||||
|
|
||||||
# Non-optional, core dependencies from here on out.
|
# Non-optional, core dependencies from here on out.
|
||||||
futures = { version = "0.3.0", default-features = false, features = ["std"] }
|
futures = { version = "0.3.0", default-features = false, features = ["std"] }
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
//!
|
//!
|
||||||
//! # Extra Features
|
//! # Extra Features
|
||||||
//!
|
//!
|
||||||
//! The [`uuid`](https://docs.rs/uuid/0.8) crate exposes extra `v{n}` features
|
//! The [`uuid`](https://docs.rs/uuid/1) crate exposes extra `v{n}` features
|
||||||
//! for generating UUIDs which are not enabled by Rocket. To enable these
|
//! for generating UUIDs which are not enabled by Rocket. To enable these
|
||||||
//! features, depend on `uuid` directly. The extra functionality can be accessed
|
//! features, depend on `uuid` directly. The extra functionality can be accessed
|
||||||
//! via both `rocket::serde::uuid::Uuid` or the direct `uuid::Uuid`; the types
|
//! via both `rocket::serde::uuid::Uuid` or the direct `uuid::Uuid`; the types
|
||||||
@ -72,36 +72,18 @@
|
|||||||
//!
|
//!
|
||||||
//! ```toml
|
//! ```toml
|
||||||
//! [dependencies.uuid]
|
//! [dependencies.uuid]
|
||||||
//! version = "0.8"
|
//! version = "1"
|
||||||
//! features = ["v1", "v4"]
|
//! features = ["v1", "v4"]
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use crate::request::FromParam;
|
use crate::request::FromParam;
|
||||||
use crate::form::{self, FromFormField, ValueField};
|
use crate::form::{self, FromFormField, ValueField};
|
||||||
|
|
||||||
/// A Universally Unique Identifier (UUID).
|
/// Error returned on [`FromParam`] or [`FromFormField`] failure.
|
||||||
///
|
///
|
||||||
/// # Examples
|
pub use uuid_::Error;
|
||||||
///
|
|
||||||
/// To parse a UUID and print it as a urn:
|
|
||||||
///
|
|
||||||
/// ```rust
|
|
||||||
/// use rocket::serde::uuid::{Uuid, Error};
|
|
||||||
///
|
|
||||||
/// # fn f() -> Result<(), Error> {
|
|
||||||
/// let uuid = Uuid::parse_str("936DA01F9ABD4d9d80C702AF85C822A8")?;
|
|
||||||
/// println!("{}", uuid.to_urn());
|
|
||||||
/// # Ok(())
|
|
||||||
/// # }
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
pub use uuid_::Uuid;
|
|
||||||
|
|
||||||
pub use uuid_::{Builder, Variant, Version};
|
pub use uuid_::{Uuid, Builder, Variant, Version, Bytes, uuid, fmt};
|
||||||
|
|
||||||
/// Type alias for the error returned on [`FromParam`] or [`FromFormField`]
|
|
||||||
/// failure.
|
|
||||||
pub type Error = <uuid_::Uuid as std::str::FromStr>::Err;
|
|
||||||
|
|
||||||
impl<'a> FromParam<'a> for Uuid {
|
impl<'a> FromParam<'a> for Uuid {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
@ -128,14 +110,13 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_from_param() {
|
fn test_from_param() {
|
||||||
let uuid_str = "c1aa1e3b-9614-4895-9ebd-705255fa5bc2";
|
let uuid_str = "c1aa1e3b-9614-4895-9ebd-705255fa5bc2";
|
||||||
let uuid_wrapper = Uuid::from_param(uuid_str.into()).unwrap();
|
let uuid = Uuid::from_param(uuid_str).unwrap();
|
||||||
assert_eq!(uuid_str, uuid_wrapper.to_string())
|
assert_eq!(uuid_str, uuid.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "InvalidLength")]
|
|
||||||
fn test_from_param_invalid() {
|
fn test_from_param_invalid() {
|
||||||
let uuid_str = "c1aa1e3b-9614-4895-9ebd-705255fa5bc2p";
|
let uuid_str = "c1aa1e3b-9614-4895-9ebd-705255fa5bc2p";
|
||||||
Uuid::from_param(uuid_str.into()).unwrap();
|
assert!(Uuid::from_param(uuid_str).is_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user