pub struct PropertyValue(/* private fields */);Expand description
A property/variable value that has been checked against
MAX_INTERPOLATED_VALUE_BYTES and is guaranteed not to exceed it.
This is the type-level gate for issue #1481: HashMap<String, PropertyValue> (rather than
HashMap<String, String>) as the map type that feeds Maven’s ${property} and Gradle’s
version.ref/$name/${name} resolution makes an oversized retained value
unrepresentable, instead of relying on a runtime check at every call site.
§Examples
use deps_core::interpolation::{MAX_INTERPOLATED_VALUE_BYTES, PropertyValue};
let value = PropertyValue::new("1.2.3".to_string()).unwrap();
assert_eq!(value.as_str(), "1.2.3");
let oversized = "x".repeat(MAX_INTERPOLATED_VALUE_BYTES + 1);
assert!(PropertyValue::new(oversized).is_err());Implementations§
Source§impl PropertyValue
impl PropertyValue
Sourcepub fn new(value: String) -> Result<Self, OversizedPropertyValue>
pub fn new(value: String) -> Result<Self, OversizedPropertyValue>
Wraps value as a PropertyValue, rejecting it if longer than
MAX_INTERPOLATED_VALUE_BYTES.
§Errors
Returns OversizedPropertyValue if value.len() exceeds
MAX_INTERPOLATED_VALUE_BYTES.
§Examples
use deps_core::interpolation::PropertyValue;
assert!(PropertyValue::new("2.0.16".to_string()).is_ok());Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the property value as a string slice.
§Examples
use deps_core::interpolation::PropertyValue;
let value = PropertyValue::new("3.2.0".to_string()).unwrap();
assert_eq!(value.as_str(), "3.2.0");Trait Implementations§
Source§impl Clone for PropertyValue
impl Clone for PropertyValue
Source§impl Debug for PropertyValue
impl Debug for PropertyValue
impl Eq for PropertyValue
Source§impl Hash for PropertyValue
impl Hash for PropertyValue
Source§impl PartialEq for PropertyValue
impl PartialEq for PropertyValue
impl StructuralPartialEq for PropertyValue
Auto Trait Implementations§
impl Freeze for PropertyValue
impl RefUnwindSafe for PropertyValue
impl Send for PropertyValue
impl Sync for PropertyValue
impl Unpin for PropertyValue
impl UnsafeUnpin for PropertyValue
impl UnwindSafe for PropertyValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.