Trait sendblue::traits::url::Url

source ·
pub trait Url: Sized {
    // Required methods
    fn from_raw_url(raw_url: RawUrl) -> Self;
    fn raw_url(&self) -> &RawUrl;

    // Provided methods
    fn new(url: &str) -> Result<Self, ValidationError> { ... }
    fn as_str(&self) -> &str { ... }
    fn url(&self) -> &RawUrl { ... }
}
Expand description

A trait for handling URLs with default implementations for common operations.

§Methods

  • new - Creates a new instance of the implementing type from a URL string.
  • as_str - Returns the URL as a string slice.
  • url - Returns a reference to the RawUrl.

Required Methods§

source

fn from_raw_url(raw_url: RawUrl) -> Self

Creates a new instance of the implementing type from a RawUrl.

§Arguments
  • raw_url - A RawUrl instance.
source

fn raw_url(&self) -> &RawUrl

Returns a reference to the RawUrl.

This method must be implemented by the type.

Provided Methods§

source

fn new(url: &str) -> Result<Self, ValidationError>

Creates a new instance of the implementing type from a URL string.

§Arguments
  • url - A string slice that holds the URL.
§Errors

Returns a ValidationError if the URL is invalid.

source

fn as_str(&self) -> &str

Returns the URL as a string slice.

source

fn url(&self) -> &RawUrl

Returns a reference to the RawUrl.

Object Safety§

This trait is not object safe.

Implementors§