sambrs/
error.rs

1use std::ffi::NulError;
2use thiserror::Error;
3
4pub type Result<T> = std::result::Result<T, Error>;
5
6#[allow(clippy::enum_variant_names)]
7#[derive(Error, Debug, PartialEq)]
8pub enum Error {
9    #[error("Failed to convert share to CString")]
10    CStringConversion(#[from] NulError),
11
12    #[error("The caller does not have access to the network resource.")]
13    AccessDenied,
14    #[error("The local device specified by the lpLocalName member is already connected to a network resource.")]
15    AlreadyAssigned,
16    #[error("The type of local device and the type of network resource do not match.")]
17    BadDevType,
18    #[error("The specified device name is not valid. This error is returned if the lpLocalName member of the NETRESOURCE structure pointed to by the lpNetResource parameter specifies a device that is not redirectable.")]
19    BadDevice,
20    #[error("The network name cannot be found. This value is returned if the lpRemoteName member of the NETRESOURCE structure pointed to by the lpNetResource parameter specifies a resource that is not acceptable to any network resource provider, either because the resource name is empty, not valid, or because the named resource cannot be located.")]
21    BadNetName,
22    #[error("The user profile is in an incorrect format.")]
23    BadProfile,
24    #[error("The specified network provider name is not valid. This error is returned if the lpProvider member of the NETRESOURCE structure pointed to by the lpNetResource parameter specifies a value that does not match any network provider.")]
25    BadProvider,
26    #[error("The specified user name is not valid.")]
27    BadUsername,
28    #[error("The router or provider is busy, possibly initializing. The caller should retry.")]
29    Busy,
30    #[error("The attempt to make the connection was canceled by the user through a dialog box from one of the network resource providers, or by a called resource.")]
31    Cancelled,
32    #[error("The system is unable to open the user profile to process persistent connections.")]
33    CannotOpenProfile,
34    #[error("The local device name has a remembered connection to another network resource. This error is returned if an entry for the device specified by lpLocalName member of the NETRESOURCE structure pointed to by the lpNetResource parameter specifies a value that is already in the user profile for a different connection than that specified in the lpNetResource parameter.")]
35    DeviceAlreadyRemembered,
36    #[error("A network-specific error occurred. Call the WNetGetLastError function to obtain a description of the error.")]
37    ExtendedError,
38    #[error("An attempt was made to access an invalid address. This error is returned if the dwFlags parameter specifies a value of CONNECT_REDIRECT, but the lpLocalName member of the NETRESOURCE structure pointed to by the lpNetResource parameter was unspecified.")]
39    InvalidAddress,
40    #[error("A parameter is incorrect. This error is returned if the dwType member of the NETRESOURCE structure pointed to by the lpNetResource parameter specifies a value other than RESOURCETYPE_DISK, RESOURCETYPE_PRINT, or RESOURCETYPE_ANY. This error is also returned if the dwFlags parameter specifies an incorrect or unknown value.")]
41    InvalidParameter,
42    #[error("The specified password is invalid and the CONNECT_INTERACTIVE flag is not set.")]
43    InvalidPassword,
44    #[error("A logon failure because of an unknown user name or a bad password.")]
45    LogonFailure,
46    #[error("No network provider accepted the given network path. This error is returned if no network provider recognized the lpRemoteName member of the NETRESOURCE structure pointed to by the lpNetResource parameter.")]
47    NoNetOrBadPath,
48    #[error("The network is unavailable.")]
49    NoNetwork,
50    #[error("The device is in use by an active process and cannot be disconnected.")]
51    DeviceInUse,
52    #[error("The name specified by the lpName parameter is not a redirected device, or the system is not currently connected to the device specified by the parameter.")]
53    NotConnected,
54    #[error("There are open files, and the fForce parameter is FALSE.")]
55    OpenFiles,
56    #[error("Unknown error.")]
57    Other,
58}