You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: filter.rs
    path of file: ./repos/diem/crates/diem-logger/src
    
    the code of the file until where you have to start completion: // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0

//! Filtering definitions for controlling what modules and levels are logged

use crate::{Level, Metadata};
use std::{env, str::FromStr};

pub struct FilterParseError;

/// A definition of the most verbose `Level` allowed, or completely off.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum LevelFilter {
    Off,
    Error,
    Warn,
    Info,
    Debug,
    Trace,
}

imp
    
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let mut parts = s.split('=').map(str::trim);
        let (name, level) = match (parts.next(), parts.next(), parts.next()) {
            // Only a level or module is provided, e.g. 'debug' or 'crate::foo'
            (Some(level_or_module), None, None) => match level_or_module.parse() {
                Ok(level) => (None, level),
                Err(_) => (Some(level_or_module), LevelFilter::max()),
            },
            // Only a name is provided, e.g. 'crate='
            (Some(name), Some(""), None) => (Some(name), LevelFilter::max()),
            // Both a name and level is provided, e.g. 'crate=debug'
            (Some(name), Some(level), None) => (Some(name), level.parse()?),
            _ => return Err(FilterParseError),
        };

        Ok(Directive::new(name, level))
    }